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

Unified Diff: net/socket/tcp_socket_win.cc

Issue 1055813006: CHECK() if Windows non-blocking connect returns 0. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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_socket_win.cc
diff --git a/net/socket/tcp_socket_win.cc b/net/socket/tcp_socket_win.cc
index 6d84fd453afac0ff4e0b2ac14af98839acbb7c4f..7ebac7c4d68dda240b32daf3bdba7749ca4217b2 100644
--- a/net/socket/tcp_socket_win.cc
+++ b/net/socket/tcp_socket_win.cc
@@ -801,30 +801,25 @@ int TCPSocketWin::DoConnect() {
result = connect(socket_, storage.addr, storage.addr_len);
}
- if (!result) {
- // Connected without waiting!
- //
- // The MSDN page for connect says:
- // With a nonblocking socket, the connection attempt cannot be completed
- // immediately. In this case, connect will return SOCKET_ERROR, and
- // WSAGetLastError will return WSAEWOULDBLOCK.
- // which implies that for a nonblocking socket, connect never returns 0.
- // It's not documented whether the event object will be signaled or not
- // if connect does return 0. So the code below is essentially dead code
- // and we don't know if it's correct.
- NOTREACHED();
-
- if (ResetEventIfSignaled(core_->read_overlapped_.hEvent))
- return OK;
- } else {
- int os_error = WSAGetLastError();
- if (os_error != WSAEWOULDBLOCK) {
- LOG(ERROR) << "connect failed: " << os_error;
- connect_os_error_ = os_error;
- int rv = MapConnectError(os_error);
- CHECK_NE(ERR_IO_PENDING, rv);
- return rv;
- }
+ // The MSDN page for connect says:
+ // With a nonblocking socket, the connection attempt cannot be completed
+ // immediately. In this case, connect will return SOCKET_ERROR, and
+ // WSAGetLastError will return WSAEWOULDBLOCK.
+ // which implies that for a nonblocking socket, connect never returns 0.
+ // It's not clear what the correct thing to do is if connect()
+ // returns 0. It's not clear whether this ever happens in practice.
+ // This CHECK() is here to verify that it doesn't.
+ // TODO(ricea): If the CHECK() fires in canary or dev, revert this
+ // CL. If it doesn't, reconsider what we want to do here long-term.
+ CHECK(result);
+
+ int os_error = WSAGetLastError();
+ if (os_error != WSAEWOULDBLOCK) {
+ LOG(ERROR) << "connect failed: " << os_error;
+ connect_os_error_ = os_error;
+ int rv = MapConnectError(os_error);
+ CHECK_NE(ERR_IO_PENDING, rv);
+ return rv;
}
// TODO(ricea): Remove ScopedTracker below once crbug.com/436634 is fixed.
« 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