Index: net/socket_stream/socket_stream.cc |
diff --git a/net/socket_stream/socket_stream.cc b/net/socket_stream/socket_stream.cc |
index 6ef8c331dd61b1fce340021a25967643221592ca..62aad61969b84d522be873af873b38133f0934e2 100644 |
--- a/net/socket_stream/socket_stream.cc |
+++ b/net/socket_stream/socket_stream.cc |
@@ -638,7 +638,7 @@ int SocketStream::DoSOCKSConnectComplete(int result) { |
if (is_secure()) |
next_state_ = STATE_SSL_CONNECT; |
else |
- DidEstablishConnection(); |
+ result = DidEstablishConnection(); |
} |
return result; |
} |
@@ -688,7 +688,7 @@ int SocketStream::DoReadWrite(int result) { |
return ERR_CONNECTION_CLOSED; |
} |
// If read is pending, try write as well. |
- // Otherwise, return the result and do next loop. |
+ // Otherwise, return the result and do next loop (to close the connection). |
if (result != ERR_IO_PENDING) { |
next_state_ = STATE_CLOSE; |
return result; |
@@ -708,6 +708,12 @@ int SocketStream::DoReadWrite(int result) { |
DidSendData(result); |
return OK; |
} |
+ // If write is not pending, return the result and do next loop (to close |
+ // the connection). |
+ if (result != 0 && result != ERR_IO_PENDING) { |
+ next_state_ = STATE_CLOSE; |
+ return result; |
+ } |
return result; |
} |