From 25cf163695aa1663a6690c4a27841fcb8e3132db Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Thu, 5 Dec 2013 20:33:49 -0800 Subject: [PATCH] Bug 942152, r=dkeeler, r=honzab --HG-- extra : rebase_source : 7f0bab4efa26e9c185b29fdb14d846035147fd2f --- security/manager/ssl/src/nsNSSIOLayer.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/security/manager/ssl/src/nsNSSIOLayer.cpp b/security/manager/ssl/src/nsNSSIOLayer.cpp index cbf6d67179f7..1071d35e506e 100644 --- a/security/manager/ssl/src/nsNSSIOLayer.cpp +++ b/security/manager/ssl/src/nsNSSIOLayer.cpp @@ -1036,7 +1036,8 @@ int32_t checkHandshake(int32_t bytesTransfered, bool wasReading, PRFileDesc* ssl_layer_fd, nsNSSSocketInfo *socketInfo) { - PRErrorCode err = PR_GetError(); + const PRErrorCode originalError = PR_GetError(); + PRErrorCode err = originalError; // This is where we work around all of those SSL servers that don't // conform to the SSL spec and shutdown a connection when we request @@ -1114,6 +1115,14 @@ int32_t checkHandshake(int32_t bytesTransfered, bool wasReading, } if (bytesTransfered < 0) { + // Remember that we encountered an error so that getSocketInfoIfRunning + // will correctly cause us to fail if another part of Gecko + // (erroneously) calls an I/O function (PR_Send/PR_Recv/etc.) again on + // this socket. Note that we use the original error because if we use + // PR_CONNECT_RESET_ERROR, we'll repeated try to reconnect. + if (originalError != PR_WOULD_BLOCK_ERROR && !socketInfo->GetErrorCode()) { + socketInfo->SetCanceled(originalError, PlainErrorMessage); + } PR_SetError(err, 0); }