summaryrefslogtreecommitdiffstats
path: root/net/socket/ssl_server_socket_nss.cc
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-21 18:29:44 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-21 18:29:44 +0000
commit55ee0e510a15dc330b08851b943caca9996e5a83 (patch)
tree0932a0f03384774eb9050beb3ef2d40b154e7ddd /net/socket/ssl_server_socket_nss.cc
parent2f040f978353a97829763d3f97ca48725b1fa0aa (diff)
downloadchromium_src-55ee0e510a15dc330b08851b943caca9996e5a83.zip
chromium_src-55ee0e510a15dc330b08851b943caca9996e5a83.tar.gz
chromium_src-55ee0e510a15dc330b08851b943caca9996e5a83.tar.bz2
Fix instability in SSL client/server sockets
When writing to a socket, net::StreamSocket::Write() may return immediately, but it may not write the whole buffer passed to it. In this case SSL sockets were not trying to call Write() again to send rest of the data, until client tries to call Write() next time. If client doesn't call Write the remaining data is never sent to the transport socket. remoting_unittests was flaky due to this bug. BUG=88726 TEST=updated net_unittest to catch the bug, remoting_unittests is not flaky Review URL: http://codereview.chromium.org/7399025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93445 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/ssl_server_socket_nss.cc')
-rw-r--r--net/socket/ssl_server_socket_nss.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/net/socket/ssl_server_socket_nss.cc b/net/socket/ssl_server_socket_nss.cc
index bdcff2c..83a382e 100644
--- a/net/socket/ssl_server_socket_nss.cc
+++ b/net/socket/ssl_server_socket_nss.cc
@@ -528,14 +528,22 @@ void SSLServerSocketNSS::BufferRecvComplete(int result) {
OnRecvComplete(result);
}
-// Do network I/O between the given buffer and the given socket.
-// Return true if some I/O performed, false otherwise (error or ERR_IO_PENDING)
+// Do as much network I/O as possible between the buffer and the
+// transport socket. Return true if some I/O performed, false
+// otherwise (error or ERR_IO_PENDING).
bool SSLServerSocketNSS::DoTransportIO() {
bool network_moved = false;
if (nss_bufs_ != NULL) {
- int nsent = BufferSend();
- int nreceived = BufferRecv();
- network_moved = (nsent > 0 || nreceived >= 0);
+ int rv;
+ // Read and write as much data as we can. The loop is neccessary
+ // because Write() may return synchronously.
+ do {
+ rv = BufferSend();
+ if (rv > 0)
+ network_moved = true;
+ } while (rv > 0);
+ if (BufferRecv() >= 0)
+ network_moved = true;
}
return network_moved;
}