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

Unified Diff: net/base/tcp_client_socket_win.cc

Issue 19515: In rare cases (when running inside QEMU), the event... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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
« net/base/tcp_client_socket.h ('K') | « net/base/tcp_client_socket.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/tcp_client_socket_win.cc
===================================================================
--- net/base/tcp_client_socket_win.cc (revision 8904)
+++ net/base/tcp_client_socket_win.cc (working copy)
@@ -88,9 +88,7 @@
if (!connect(socket_, ai->ai_addr, static_cast<int>(ai->ai_addrlen))) {
// Connected without waiting!
- CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_OBJECT_0);
- BOOL ok = WSAResetEvent(overlapped_.hEvent);
- CHECK(ok);
+ WaitForAndResetEvent();
TRACE_EVENT_END("socket.connect", this, "");
return OK;
}
@@ -170,14 +168,12 @@
buffer_.buf = buf;
TRACE_EVENT_BEGIN("socket.read", this, "");
- // TODO(wtc): Remove the CHECKs after enough testing.
+ // TODO(wtc): Remove the CHECK after enough testing.
CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_TIMEOUT);
DWORD num, flags = 0;
int rv = WSARecv(socket_, &buffer_, 1, &num, &flags, &overlapped_, NULL);
if (rv == 0) {
- CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_OBJECT_0);
- BOOL ok = WSAResetEvent(overlapped_.hEvent);
- CHECK(ok);
+ WaitForAndResetEvent();
TRACE_EVENT_END("socket.read", this, StringPrintf("%d bytes", num));
// Because of how WSARecv fills memory when used asynchronously, Purify
@@ -199,15 +195,6 @@
return MapWinsockError(err);
}
-// TODO(wtc): This temporary function is intended to determine the return
-// value and error code of the WaitForSingleObject call in
-// TCPClientSocket::Write if it doesn't return the expected WAIT_OBJECT_0.
-// See http://crbug.com/6500.
-static void CrashBug6500(DWORD wait_rv, DWORD wait_error) {
- // wait_error is meaningful only if wait_rv is WAIT_FAILED.
- CHECK(false) << wait_rv << wait_error;
-}
-
int TCPClientSocket::Write(const char* buf,
int buf_len,
CompletionCallback* callback) {
@@ -219,18 +206,12 @@
buffer_.buf = const_cast<char*>(buf);
TRACE_EVENT_BEGIN("socket.write", this, "");
- // TODO(wtc): Remove the CHECKs after enough testing.
+ // TODO(wtc): Remove the CHECK after enough testing.
CHECK(WaitForSingleObject(overlapped_.hEvent, 0) == WAIT_TIMEOUT);
DWORD num;
int rv = WSASend(socket_, &buffer_, 1, &num, 0, &overlapped_, NULL);
if (rv == 0) {
- DWORD wait_rv = WaitForSingleObject(overlapped_.hEvent, 0);
- if (wait_rv != WAIT_OBJECT_0) {
- DWORD wait_error = GetLastError();
- CrashBug6500(wait_rv, wait_error);
- }
- BOOL ok = WSAResetEvent(overlapped_.hEvent);
- CHECK(ok);
+ WaitForAndResetEvent();
TRACE_EVENT_END("socket.write", this, StringPrintf("%d bytes", num));
return static_cast<int>(num);
}
@@ -379,5 +360,13 @@
}
}
+void TCPClientSocket::WaitForAndResetEvent() {
+ // TODO(wtc): Remove the CHECKs after enough testing.
+ DWORD wait_rv = WaitForSingleObject(overlapped_.hEvent, INFINITE);
+ CHECK(wait_rv == WAIT_OBJECT_0);
+ BOOL ok = WSAResetEvent(overlapped_.hEvent);
+ CHECK(ok);
+}
+
} // namespace net
« net/base/tcp_client_socket.h ('K') | « net/base/tcp_client_socket.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698