diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 19:30:28 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 19:30:28 +0000 |
commit | 13e4418cd94e979f87299cfa629823a71d8e73d4 (patch) | |
tree | 9ef230e5a545aaddacba265c07cde17de685ef0c /net/test/test_server_win.cc | |
parent | e1031593bebcddda82503d92b4a7a79b7f2d36e5 (diff) | |
download | chromium_src-13e4418cd94e979f87299cfa629823a71d8e73d4.zip chromium_src-13e4418cd94e979f87299cfa629823a71d8e73d4.tar.gz chromium_src-13e4418cd94e979f87299cfa629823a71d8e73d4.tar.bz2 |
Revert 64070 - Revert 64065 - testserver.py listens on ephemeral ports by default.
If --port is specified on the command line, testserver.py will listen on that port, otherwise it will listen on an ephemeral port. If --startup_pipe is specified, the port number is written to the pipe as a 2 byte unsigned int in host order.
TestServer by default spawns testserver.py to listen on an ephemeral port and reads the port value from the pipe. If necessary, the port can still be fixed using TestServer::ForcePort, but that will hopefully get deprecated quickly.
BUG=56814
TEST=try bots pass
Review URL: http://codereview.chromium.org/3549003
TBR=cbentzel@chromium.org
Review URL: http://codereview.chromium.org/4165004
TBR=cbentzel@chromium.org
Review URL: http://codereview.chromium.org/4146008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64118 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/test/test_server_win.cc')
-rw-r--r-- | net/test/test_server_win.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/net/test/test_server_win.cc b/net/test/test_server_win.cc index a8b3678..cfc7178 100644 --- a/net/test/test_server_win.cc +++ b/net/test/test_server_win.cc @@ -149,11 +149,24 @@ bool TestServer::LaunchPython(const FilePath& testserver_path) { } bool TestServer::WaitToStart() { - char buf[8]; - DWORD bytes_read; - BOOL result = ReadFile(child_fd_, buf, sizeof(buf), &bytes_read, NULL); + 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_fd_, buffer + bytes_read, bytes_max - bytes_read, + &num_bytes, NULL)) + break; + if (num_bytes <= 0) + break; + bytes_read += num_bytes; + } child_fd_.Close(); - return result && bytes_read > 0; + if (bytes_read < bytes_max) + return false; + host_port_pair_.set_port(port); + return true; } bool TestServer::CheckCATrusted() { |