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

Unified Diff: net/base/nss_memio.c

Issue 17105003: Gracefully handle an asynchronous write disconnect when an SSL read is pending (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment updates Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/nss_memio.c
diff --git a/net/base/nss_memio.c b/net/base/nss_memio.c
index bd0471067f4e57e31b39d09889f0caa1bdeef378..9e6e84611cfb257a9a944cd9ff2072770616896a 100644
--- a/net/base/nss_memio.c
+++ b/net/base/nss_memio.c
@@ -228,8 +228,17 @@ static int PR_CALLBACK memio_Recv(PRFileDesc *fd, void *buf, PRInt32 len,
rv = memio_buffer_get(mb, buf, len);
if (rv == 0 && !secret->eof) {
secret->read_requested = len;
+ /* If there is no more data in the buffer, report any pending errors
+ * that were previously observed. Note that both the readbuf and the
+ * writebuf are checked for errors, since the application may have
+ * encountered a socket error while writing that would otherwise not
+ * be reported until the application attempted to write again - which
+ * it may never do.
+ */
if (mb->last_err)
PR_SetError(mb->last_err, 0);
+ else if (secret->writebuf.last_err)
+ PR_SetError(secret->writebuf.last_err, 0);
else
PR_SetError(PR_WOULD_BLOCK_ERROR, 0);
return -1;
@@ -256,6 +265,11 @@ static int PR_CALLBACK memio_Send(PRFileDesc *fd, const void *buf, PRInt32 len,
mb = &secret->writebuf;
PR_ASSERT(mb->bufsize);
+ /* Note that the read error state is not reported, because it cannot be
+ * reported until all buffered data has been read. If there is an error
+ * with the next layer, attempting to call Send again will report the
+ * error appropriately.
+ */
if (mb->last_err) {
PR_SetError(mb->last_err, 0);
return -1;
« no previous file with comments | « no previous file | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698