Status: Assigned
Owner: [email protected]
CC: [email protected]
Labels: Type-Bug Pri-2 OS-Windows Area-BrowserBackend Size-Medium

New issue 9258 by [email protected]: Review the two  
WaitForSingleObject(INFINITE) calls in tcp_client_socket_win.cc
http://code.google.com/p/chromium/issues/detail?id=9258

tcp_client_socket_win.cc has two WaitForSingleObject calls with
INFINITE timeout.  I need to review those two calls.  Ideally
they should not block the IO thread indefinitely if Windows or
some other thread is malfunctioning.

The first call is in TCPClientSocket::Disconnect():

   // Cancel any pending IO and wait for it to be aborted.
   if (wait_state_ == WAITING_READ || wait_state_ == WAITING_WRITE) {
     CancelIo(reinterpret_cast<HANDLE>(socket_));
     WaitForSingleObject(overlapped_.hEvent, INFINITE);
     wait_state_ = NOT_WAITING;
   }

Here we call WaitForSingleObject on the IO thread because we often
get here via the TCPClientSocket destructor, and the caller of
the TCPClientSocket destructor expects a synchronous socket closure.

The second call to WaitForSingleObject is in
TCPClientSocket::WaitForAndResetEvent():

   DWORD wait_rv = WaitForSingleObject(overlapped_.hEvent, INFINITE);
   CHECK(wait_rv == WAIT_OBJECT_0);
   BOOL ok = WSAResetEvent(overlapped_.hEvent);
   CHECK(ok);

Here we call WaitForSingleObject on the IO thread as a performance
optimization, to avoid a thread context switch.  It is straightforward
to move this WaitForSingleObject call to the thread pool.





--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/group/chromium-bugs
-~----------~----~----~----~------~----~------~--~---

Reply via email to