| Index: net/test/test_server_win.cc
|
| diff --git a/net/test/test_server_win.cc b/net/test/test_server_win.cc
|
| index c6e10d5bbc61d2d6cac8b5e69fa3b9e2a3bfe64b..64437cd46d6a2aa8348d67c8b63f0400a8b71d7c 100644
|
| --- a/net/test/test_server_win.cc
|
| +++ b/net/test/test_server_win.cc
|
| @@ -156,11 +156,20 @@ bool TestServer::WaitToStart() {
|
| NewRunnableFunction(UnblockPipe, child_write_fd_.Get(), &unblocked),
|
| TestTimeouts::action_max_timeout_ms());
|
|
|
| - char buf[8];
|
| - DWORD bytes_read;
|
| - BOOL result = ReadFile(child_read_fd_.Get(), buf, sizeof(buf), &bytes_read,
|
| - NULL);
|
| -
|
| + // Try to read two bytes from the pipe indicating the ephemeral port number.
|
| + uint16 port;
|
| + uint8* buffer = reinterpret_cast<uint8*>(&port);
|
| + DWORD bytes_read = 0;
|
| + DWORD bytes_max = sizeof(port);
|
| + while (bytes_read < bytes_max) {
|
| + DWORD num_bytes;
|
| + if (!ReadFile(child_read_fd_, buffer + bytes_read, bytes_max - bytes_read,
|
| + &num_bytes, NULL))
|
| + break;
|
| + if (num_bytes <= 0)
|
| + break;
|
| + bytes_read += num_bytes;
|
| + }
|
| thread.Stop();
|
| child_read_fd_.Close();
|
| child_write_fd_.Close();
|
| @@ -169,7 +178,12 @@ bool TestServer::WaitToStart() {
|
| if (unblocked)
|
| return false;
|
|
|
| - return result && bytes_read > 0;
|
| + // If not enough bytes were read, fail.
|
| + if (bytes_read < bytes_max)
|
| + return false;
|
| +
|
| + host_port_pair_.set_port(port);
|
| + return true;
|
| }
|
|
|
| bool TestServer::CheckCATrusted() {
|
|
|