Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2147)

Unified Diff: net/socket/tcp_client_socket_win.cc

Issue 12546004: Retrieve more accurate error code (WSAECONNRESET vs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/tcp_client_socket_win.cc
===================================================================
--- net/socket/tcp_client_socket_win.cc (revision 185536)
+++ net/socket/tcp_client_socket_win.cc (working copy)
@@ -266,7 +266,7 @@
TCPClientSocketWin* socket)
: read_buffer_length_(0),
write_buffer_length_(0),
- disable_overlapped_reads_(g_disable_overlapped_reads),
+ disable_overlapped_reads_(true),
wtc 2013/03/06 17:33:43 Please ignore this change. I need this temporary c
non_blocking_reads_initialized_(false),
socket_(socket),
ALLOW_THIS_IN_INITIALIZER_LIST(reader_(this)),
@@ -840,6 +840,9 @@
FD_READ | FD_CLOSE);
core_->non_blocking_reads_initialized_ = true;
}
+ // Sometimes core_->read_overlapped_.hEvent is signaled at this
+ // point. It is usually the 3rd-5th times we call recv() on the
+ // socket, never the first time.
int rv = recv(socket_, buf->data(), buf_len, 0);
if (rv == SOCKET_ERROR) {
int os_error = WSAGetLastError();
@@ -858,6 +861,8 @@
}
net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_RECEIVED, rv,
buf->data());
+ BOOL ok = WSAResetEvent(core_->read_overlapped_.hEvent);
rvargas (doing something else) 2013/03/06 23:08:49 I think this can cause unwanted hangs (unlikely, b
Pat Meenan 2013/03/07 15:11:04 What are you trying to solve by manually resetting
+ CHECK(ok);
return rv;
}
} else {
@@ -1022,25 +1027,20 @@
WSANETWORKEVENTS network_events;
int rv = WSAEnumNetworkEvents(socket_, core_->read_overlapped_.hEvent,
&network_events);
+ AssertEventNotSignaled(core_->read_overlapped_.hEvent);
wtc 2013/03/06 17:33:43 This asserts that WSAEnumNetworkEvents resets the
rvargas (doing something else) 2013/03/06 23:08:49 Sounds like a race to me.
Pat Meenan 2013/03/07 15:11:04 Agreed, it's not atomic so it's theoretically poss
if (rv == SOCKET_ERROR) {
+ NOTREACHED();
rvargas (doing something else) 2013/03/06 23:08:49 I'm assuming this is for development purposes... I
os_error = WSAGetLastError();
rv = MapSystemError(os_error);
- } else if (network_events.lNetworkEvents & FD_READ) {
+ } else if (network_events.lNetworkEvents) {
rv = DoRead(core_->read_iobuffer_, core_->read_buffer_length_,
read_callback_);
wtc 2013/03/06 17:33:43 I got the inspiration of this change from the old-
Pat Meenan 2013/03/07 15:11:04 Is the last error from the recv() here as granular
wtc 2013/03/14 01:24:45 Yes, in fact it is better. When the peer resets t
if (rv == ERR_IO_PENDING)
return;
- } else if (network_events.lNetworkEvents & FD_CLOSE) {
- if (network_events.iErrorCode[FD_CLOSE_BIT]) {
- rv = MapSystemError(network_events.iErrorCode[FD_CLOSE_BIT]);
- net_log_.AddEvent(NetLog::TYPE_SOCKET_READ_ERROR,
- CreateNetLogSocketErrorCallback(rv, os_error));
wtc 2013/03/06 17:33:43 If you prefer a smaller change, I can call DoRead(
- } else {
- rv = 0;
- }
} else {
// This should not happen but I have seen cases where we will get
// signaled but the network events flags are all clear (0).
wtc 2013/03/06 17:33:43 The WSAResetEvent call I added on line 864 elimina
rvargas (doing something else) 2013/03/06 23:08:49 I'm thinking that we either accept a spurious wake
Pat Meenan 2013/03/07 15:11:04 How often do the Spurious wake-ups happen from IsC
wtc 2013/03/14 01:24:45 I confirmed that the spurious wake-ups are NOT cau
+ NOTREACHED();
rvargas (doing something else) 2013/03/06 23:08:49 same thing here. If this triggers for a developer
core_->WatchForRead();
return;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698