Index: net/socket/stream_listen_socket.cc |
diff --git a/net/socket/stream_listen_socket.cc b/net/socket/stream_listen_socket.cc |
index e6ae74ef708c5359760d42b8bb08cfb8ac05f049..fd164a556d5b3f0235794e4e939be61f4cd7459d 100644 |
--- a/net/socket/stream_listen_socket.cc |
+++ b/net/socket/stream_listen_socket.cc |
@@ -252,11 +252,16 @@ void StreamListenSocket::OnObjectSignaled(HANDLE object) { |
return; |
} |
- if (!(ev.lNetworkEvents & FD_CLOSE)) { |
- // The object was reset by WSAEnumNetworkEvents. Watch for the next signal. |
- watcher_.StartWatching(object, this); |
+ // If both FD_CLOSE and FD_READ are set we only call Read(). |
+ // This will cause OnObjectSignaled to be called immediately again |
+ // unless this socket is destroyed in Read(). |
+ if ((ev.lNetworkEvents & (FD_CLOSE | FD_READ)) == FD_CLOSE) { |
+ Close(); |
+ // Close might have deleted this object. We should return immediately. |
+ return; |
} |
- |
+ // The object was reset by WSAEnumNetworkEvents. Watch for the next signal. |
+ watcher_.StartWatching(object, this); |
if (ev.lNetworkEvents == 0) { |
// Occasionally the event is set even though there is no new data. |
@@ -271,14 +276,9 @@ void StreamListenSocket::OnObjectSignaled(HANDLE object) { |
has_pending_reads_ = true; |
} else { |
Read(); |
- // Read doesn't call Close() in Windows case. We keep going. |
+ // Read might have deleted this object. We should return immediately. |
} |
} |
- if (ev.lNetworkEvents & FD_CLOSE) { |
- Close(); |
- // Close might have deleted this object. We should return immediately. |
- return; |
- } |
} |
#elif defined(OS_POSIX) |
void StreamListenSocket::OnFileCanReadWithoutBlocking(int fd) { |