Chromium Code Reviews| Index: chrome/browser/nacl_host/nacl_process_host.cc |
| =================================================================== |
| --- chrome/browser/nacl_host/nacl_process_host.cc (revision 170891) |
| +++ chrome/browser/nacl_host/nacl_process_host.cc (working copy) |
| @@ -662,10 +662,27 @@ |
| #if defined(OS_POSIX) |
| SocketDescriptor NaClProcessHost::GetDebugStubSocketHandle() { |
| - SocketDescriptor s = net::TCPListenSocket::CreateAndBind("127.0.0.1", |
| - kDebugStubPort); |
| + NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
| + SocketDescriptor s; |
| + // We allocate ephemeral port for debug stub tests. The port number is passed |
|
Mark Seaborn
2012/12/05 18:00:47
"ephemeral port" -> "currently unused TCP port"
halyavin
2012/12/06 15:35:01
Done.
|
| + // to the test via debug stub port listener. |
| + if (nacl_browser->HasGdbDebugStubPortListener()) { |
| + int port; |
| + s = net::TCPListenSocket::CreateAndBindAnyPort("127.0.0.1", &port); |
| + if (s != net::TCPListenSocket::kInvalidSocket) { |
| + nacl_browser->FireGdbDebugStubPortOpened(port); |
| + } |
| + } else { |
| + s = net::TCPListenSocket::CreateAndBind("127.0.0.1", kDebugStubPort); |
| + } |
| + if (s == net::TCPListenSocket::kInvalidSocket) { |
| + LOG(ERROR) << "failed to open socket for debug stub"; |
| + return net::TCPListenSocket::kInvalidSocket; |
| + } |
| if (listen(s, 1)) { |
| LOG(ERROR) << "listen() failed on debug stub socket"; |
| + if (HANDLE_EINTR(close(s)) < 0) |
| + PLOG(ERROR) << "failed to close debug stub socket"; |
| return net::TCPListenSocket::kInvalidSocket; |
| } |
| return s; |