diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-26 10:06:20 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-26 10:06:20 +0000 |
commit | 75d0ffdbbf0642dc71cbe5e60dc00a6b256138db (patch) | |
tree | 4674df4e8dff613e9bdfc3ca0bb3fdc8511dec0e /net | |
parent | 7a09b50b5cc6c81944d2167983fa7b52bb1dd59b (diff) | |
download | chromium_src-75d0ffdbbf0642dc71cbe5e60dc00a6b256138db.zip chromium_src-75d0ffdbbf0642dc71cbe5e60dc00a6b256138db.tar.gz chromium_src-75d0ffdbbf0642dc71cbe5e60dc00a6b256138db.tar.bz2 |
Fixed UnblockPipe() in test_server_win.cc to work with any number of bytes
Since ReadData() can be told to read any number of bytes, UnblockPipe()
must write at least that number of bytes to guarantee to unblock ReadData().
BUG=53934
TEST=Manual
Review URL: http://codereview.chromium.org/5329004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67445 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/test/test_server_win.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/net/test/test_server_win.cc b/net/test/test_server_win.cc index b5001aa..79eb8dd 100644 --- a/net/test/test_server_win.cc +++ b/net/test/test_server_win.cc @@ -75,15 +75,18 @@ bool LaunchTestServerAsJob(const CommandLine& cmdline, return true; } -void UnblockPipe(HANDLE handle, bool* unblocked) { - static const char kUnblock[] = "UNBLOCK"; +// Writes |size| bytes to |handle| and sets |*unblocked| to true. +// Used as a crude timeout mechanism by ReadData(). +void UnblockPipe(HANDLE handle, DWORD size, bool* unblocked) { + std::string unblock_data(size, '\0'); // Unblock the ReadFile in TestServer::WaitToStart by writing to the pipe. // Make sure the call succeeded, otherwise we are very likely to hang. DWORD bytes_written = 0; - LOG(WARNING) << "Timeout reached; unblocking pipe"; - CHECK(WriteFile(handle, kUnblock, arraysize(kUnblock), &bytes_written, + LOG(WARNING) << "Timeout reached; unblocking pipe by writing " + << size << " bytes"; + CHECK(WriteFile(handle, unblock_data.data(), size, &bytes_written, NULL)); - CHECK_EQ(arraysize(kUnblock), bytes_written); + CHECK_EQ(size, bytes_written); *unblocked = true; } @@ -98,8 +101,9 @@ bool ReadData(HANDLE read_fd, HANDLE write_fd, // Prepare a timeout in case the server fails to start. bool unblocked = false; - thread.message_loop()->PostDelayedTask(FROM_HERE, - NewRunnableFunction(UnblockPipe, write_fd, &unblocked), + thread.message_loop()->PostDelayedTask( + FROM_HERE, + NewRunnableFunction(UnblockPipe, write_fd, bytes_max, &unblocked), TestTimeouts::action_max_timeout_ms()); DWORD bytes_read = 0; |