summaryrefslogtreecommitdiffstats
path: root/net/socket/tcp_client_socket_win.h
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-21 18:00:49 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-21 18:00:49 +0000
commitd95a570dba12fe3e7b10bc8c877111b10180ea30 (patch)
treeca4d2ad34c5d05b894526340db84d741e9bd84d6 /net/socket/tcp_client_socket_win.h
parentf5e8c866d2bac29ef0418f3e12ea157ac5b6dafe (diff)
downloadchromium_src-d95a570dba12fe3e7b10bc8c877111b10180ea30.zip
chromium_src-d95a570dba12fe3e7b10bc8c877111b10180ea30.tar.gz
chromium_src-d95a570dba12fe3e7b10bc8c877111b10180ea30.tar.bz2
Always fallback to the next address when doing TCP connect (winsock impl).
Before it would only try the next address in the list, for specific OS errors. Also did a slight refactoring to use a state machine for Connect(). (This is the same patch as r47728, but for windows implementation). BUG=44490 Review URL: http://codereview.chromium.org/2099010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47932 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/tcp_client_socket_win.h')
-rw-r--r--net/socket/tcp_client_socket_win.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/net/socket/tcp_client_socket_win.h b/net/socket/tcp_client_socket_win.h
index d1a2148..a2b1fcf 100644
--- a/net/socket/tcp_client_socket_win.h
+++ b/net/socket/tcp_client_socket_win.h
@@ -45,12 +45,34 @@ class TCPClientSocketWin : public ClientSocket, NonThreadSafe {
virtual bool SetSendBufferSize(int32 size);
private:
+ // State machine for connecting the socket.
+ enum ConnectState {
+ CONNECT_STATE_CONNECT,
+ CONNECT_STATE_CONNECT_COMPLETE,
+ CONNECT_STATE_NONE,
+ };
+
class Core;
- // Performs the actual connect(). Returns a net error code.
+ // State machine used by Connect().
+ int DoConnectLoop(int result);
int DoConnect();
+ int DoConnectComplete(int result);
+
+ // Helper used by Disconnect(), which disconnects minus the logging and
+ // resetting of current_ai_.
+ void DoDisconnect();
+
+ // Returns true if a Connect() is in progress.
+ bool waiting_connect() const {
+ return next_connect_state_ != CONNECT_STATE_NONE;
+ }
int CreateSocket(const struct addrinfo* ai);
+
+ // Called after Connect() has completed with |net_error|.
+ void LogConnectCompletion(int net_error);
+
void DoReadCallback(int rv);
void DoWriteCallback(int rv);
void DidCompleteConnect();
@@ -66,7 +88,6 @@ class TCPClientSocketWin : public ClientSocket, NonThreadSafe {
const struct addrinfo* current_ai_;
// The various states that the socket could be in.
- bool waiting_connect_;
bool waiting_read_;
bool waiting_write_;
@@ -81,6 +102,9 @@ class TCPClientSocketWin : public ClientSocket, NonThreadSafe {
// External callback; called when write is complete.
CompletionCallback* write_callback_;
+ // The next state for the Connect() state machine.
+ ConnectState next_connect_state_;
+
BoundNetLog net_log_;
DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin);