diff options
author | ukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 10:16:46 +0000 |
---|---|---|
committer | ukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 10:16:46 +0000 |
commit | 6f32e7e3660ebdf9a13a8c96d83f1a52d0d9341c (patch) | |
tree | a6ee521486e23609baa2cdd6bc06457ddb083fa0 /net | |
parent | bf30b627dd660f699c9e2e7c243a3df13a9264b7 (diff) | |
download | chromium_src-6f32e7e3660ebdf9a13a8c96d83f1a52d0d9341c.zip chromium_src-6f32e7e3660ebdf9a13a8c96d83f1a52d0d9341c.tar.gz chromium_src-6f32e7e3660ebdf9a13a8c96d83f1a52d0d9341c.tar.bz2 |
Set STATE_CLOSE when error occured.
Finish() when entered bad state.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/345025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30569 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/socket_stream/socket_stream.cc | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/net/socket_stream/socket_stream.cc b/net/socket_stream/socket_stream.cc index a74eb13..5744e7d 100644 --- a/net/socket_stream/socket_stream.cc +++ b/net/socket_stream/socket_stream.cc @@ -215,6 +215,7 @@ void SocketStream::SetClientSocketFactory( int SocketStream::DidEstablishConnection() { if (!socket_.get() || !socket_->IsConnected()) { + next_state_ = STATE_CLOSE; return ERR_CONNECTION_FAILED; } next_state_ = STATE_READ_WRITE; @@ -349,8 +350,8 @@ void SocketStream::DoLoop(int result) { return; default: NOTREACHED() << "bad state"; - result = ERR_UNEXPECTED; - break; + Finish(result); + return; } } while (result != ERR_IO_PENDING); } @@ -408,6 +409,8 @@ int SocketStream::DoResolveHost() { int SocketStream::DoResolveHostComplete(int result) { if (result == OK) next_state_ = STATE_TCP_CONNECT; + else + next_state_ = STATE_CLOSE; // TODO(ukai): if error occured, reconsider proxy after error. return result; } @@ -421,8 +424,10 @@ int SocketStream::DoTcpConnect() { int SocketStream::DoTcpConnectComplete(int result) { // TODO(ukai): if error occured, reconsider proxy after error. - if (result != OK) + if (result != OK) { + next_state_ = STATE_CLOSE; return result; + } if (proxy_mode_ == kTunnelProxy) next_state_ = STATE_WRITE_TUNNEL_HEADERS; @@ -495,8 +500,10 @@ int SocketStream::DoWriteTunnelHeaders() { int SocketStream::DoWriteTunnelHeadersComplete(int result) { DCHECK_EQ(kTunnelProxy, proxy_mode_); - if (result < 0) + if (result < 0) { + next_state_ = STATE_CLOSE; return result; + } tunnel_request_headers_bytes_sent_ += result; if (tunnel_request_headers_bytes_sent_ < @@ -530,8 +537,10 @@ int SocketStream::DoReadTunnelHeaders() { int SocketStream::DoReadTunnelHeadersComplete(int result) { DCHECK_EQ(kTunnelProxy, proxy_mode_); - if (result < 0) + if (result < 0) { + next_state_ = STATE_CLOSE; return result; + } if (result == 0) { // 0 indicates end-of-file, so socket was closed. @@ -599,6 +608,7 @@ int SocketStream::DoReadTunnelHeadersComplete(int result) { default: break; } + next_state_ = STATE_CLOSE; return ERR_TUNNEL_CONNECTION_FAILED; } @@ -645,14 +655,18 @@ int SocketStream::DoSSLConnectComplete(int result) { if (result == OK) result = DidEstablishConnection(); + else + next_state_ = STATE_CLOSE; return result; } int SocketStream::DoReadWrite(int result) { if (result < OK) { + next_state_ = STATE_CLOSE; return result; } if (!socket_.get() || !socket_->IsConnected()) { + next_state_ = STATE_CLOSE; return ERR_CONNECTION_CLOSED; } @@ -667,12 +681,15 @@ int SocketStream::DoReadWrite(int result) { return OK; } else if (result == 0) { // 0 indicates end-of-file, so socket was closed. + next_state_ = STATE_CLOSE; return ERR_CONNECTION_CLOSED; } // If read is pending, try write as well. // Otherwise, return the result and do next loop. - if (result != ERR_IO_PENDING) + if (result != ERR_IO_PENDING) { + next_state_ = STATE_CLOSE; return result; + } } // Read is pending. DCHECK(read_buf_); |