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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/socket/tcp_socket.h" 5 #include "net/socket/tcp_socket.h"
6 #include "net/socket/tcp_socket_win.h" 6 #include "net/socket/tcp_socket_win.h"
7 7
8 #include <mstcpip.h> 8 #include <mstcpip.h>
9 9
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 return ERR_ADDRESS_INVALID; 794 return ERR_ADDRESS_INVALID;
795 795
796 int result; 796 int result;
797 { 797 {
798 // TODO(ricea): Remove ScopedTracker below once crbug.com/436634 is fixed. 798 // TODO(ricea): Remove ScopedTracker below once crbug.com/436634 is fixed.
799 tracked_objects::ScopedTracker tracking_profile( 799 tracked_objects::ScopedTracker tracking_profile(
800 FROM_HERE_WITH_EXPLICIT_FUNCTION("436634 connect()")); 800 FROM_HERE_WITH_EXPLICIT_FUNCTION("436634 connect()"));
801 result = connect(socket_, storage.addr, storage.addr_len); 801 result = connect(socket_, storage.addr, storage.addr_len);
802 } 802 }
803 803
804 if (!result) { 804 // The MSDN page for connect says:
805 // Connected without waiting! 805 // With a nonblocking socket, the connection attempt cannot be completed
806 // 806 // immediately. In this case, connect will return SOCKET_ERROR, and
807 // The MSDN page for connect says: 807 // WSAGetLastError will return WSAEWOULDBLOCK.
808 // With a nonblocking socket, the connection attempt cannot be completed 808 // which implies that for a nonblocking socket, connect never returns 0.
809 // immediately. In this case, connect will return SOCKET_ERROR, and 809 // It's not clear what the correct thing to do is if connect()
810 // WSAGetLastError will return WSAEWOULDBLOCK. 810 // returns 0. It's not clear whether this ever happens in practice.
811 // which implies that for a nonblocking socket, connect never returns 0. 811 // This CHECK() is here to verify that it doesn't.
812 // It's not documented whether the event object will be signaled or not 812 // TODO(ricea): If the CHECK() fires in canary or dev, revert this
813 // if connect does return 0. So the code below is essentially dead code 813 // CL. If it doesn't, reconsider what we want to do here long-term.
814 // and we don't know if it's correct. 814 CHECK(result);
815 NOTREACHED();
816 815
817 if (ResetEventIfSignaled(core_->read_overlapped_.hEvent)) 816 int os_error = WSAGetLastError();
818 return OK; 817 if (os_error != WSAEWOULDBLOCK) {
819 } else { 818 LOG(ERROR) << "connect failed: " << os_error;
820 int os_error = WSAGetLastError(); 819 connect_os_error_ = os_error;
821 if (os_error != WSAEWOULDBLOCK) { 820 int rv = MapConnectError(os_error);
822 LOG(ERROR) << "connect failed: " << os_error; 821 CHECK_NE(ERR_IO_PENDING, rv);
823 connect_os_error_ = os_error; 822 return rv;
824 int rv = MapConnectError(os_error);
825 CHECK_NE(ERR_IO_PENDING, rv);
826 return rv;
827 }
828 } 823 }
829 824
830 // TODO(ricea): Remove ScopedTracker below once crbug.com/436634 is fixed. 825 // TODO(ricea): Remove ScopedTracker below once crbug.com/436634 is fixed.
831 tracked_objects::ScopedTracker tracking_profile( 826 tracked_objects::ScopedTracker tracking_profile(
832 FROM_HERE_WITH_EXPLICIT_FUNCTION("436634 WatchForRead()")); 827 FROM_HERE_WITH_EXPLICIT_FUNCTION("436634 WatchForRead()"));
833 828
834 core_->WatchForRead(); 829 core_->WatchForRead();
835 return ERR_IO_PENDING; 830 return ERR_IO_PENDING;
836 } 831 }
837 832
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 1032
1038 waiting_read_ = false; 1033 waiting_read_ = false;
1039 core_->read_iobuffer_ = NULL; 1034 core_->read_iobuffer_ = NULL;
1040 core_->read_buffer_length_ = 0; 1035 core_->read_buffer_length_ = 0;
1041 1036
1042 DCHECK_NE(rv, ERR_IO_PENDING); 1037 DCHECK_NE(rv, ERR_IO_PENDING);
1043 base::ResetAndReturn(&read_callback_).Run(rv); 1038 base::ResetAndReturn(&read_callback_).Run(rv);
1044 } 1039 }
1045 1040
1046 } // namespace net 1041 } // namespace net
OLDNEW
« 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