I had these modules listed as being owned by me, but they are really owned by
wangke, correcting.
diff --git a/testing/mochitest/ssltunnel/ssltunnel.cpp b/testing/mochitest/ssltunnel/ssltunnel.cpp
--- a/testing/mochitest/ssltunnel/ssltunnel.cpp
+++ b/testing/mochitest/ssltunnel/ssltunnel.cpp
@@ -421,6 +421,7 @@
{ci->client_sock, PR_POLL_READ, 0},
{other_sock, PR_POLL_READ, 0}
};
+ PRBool socketErrorState[2] = {PR_FALSE, PR_FALSE};
while (!((client_error||client_done) && buffers[0].empty() && buffers[1].empty()))
{
@@ -448,6 +449,7 @@
if (out_flags & (PR_POLL_EXCEPT | PR_POLL_ERR | PR_POLL_HUP))
{
client_error = true;
+ socketErrorState[s] = PR_TRUE;
// We got a fatal error state on the socket. Clear the output buffer
// for this socket to break the main loop, we will never more be able
// to send those data anyway.
@@ -468,10 +470,22 @@
else if (bytesRead < 0)
{
if (PR_GetError() != PR_WOULD_BLOCK_ERROR)
- client_error = true;
+ {
+ // We are in error state, indicate that the connection was
+ // not closed gracefully
+ client_error = true;
+ socketErrorState[s] = PR_TRUE;
+ // Wipe out our send buffer, we cannot send it anyway.
+ buffers[s2].bufferhead = buffers[s2].buffertail = buffers[s2].buffer;
+ }
}
else
{
+ // If the other socket is in error state (unable to send/receive)
+ // throw this data away and continue loop
+ if (socketErrorState[s2])
+ continue;
+
buffers[s].buffertail += bytesRead;
// We have to accept and handle the initial CONNECT request here
@@ -528,6 +542,7 @@
{
if (PR_GetError() != PR_WOULD_BLOCK_ERROR) {
client_error = true;
+ socketErrorState[s] = PR_TRUE;
// We got a fatal error while writting the buffer. Clear it to break
// the main loop, we will never more be able to send it.
buffers[s2].bufferhead = buffers[s2].buffertail = buffers[s2].buffer;