I once wrote this patch to solve a problem which I logged to be:
 Let EAGAIN be fatal for write to socket. Needed
 to unlock a hung connection where the www client has
 stopped reading its socket.

I cannot remember the details so I post the patch in hope it makes
sense to anyone. Possibly I have solved the problem at the wrong place.
Anyhow, here goes the patch:

Index: crypto/bio/bss_conn.c
===================================================================
--- crypto/bio/bss_conn.c       (revision 31831)
+++ crypto/bio/bss_conn.c       (revision 31832)
@@ -444,7 +444,11 @@
        if (ret <= 0)
                {
                if (BIO_sock_should_retry(ret))
-                       BIO_set_retry_write(b);
+                       if (get_last_socket_error() == EAGAIN) {
+                               get_last_socket_error() = ECONNRESET;
+                               shutdown(b->num, SHUT_WR);
+                       } else
+                               BIO_set_retry_write(b);
                }
        return(ret);
        }
Index: crypto/bio/bss_sock.c
===================================================================
--- crypto/bio/bss_sock.c       (revision 31831)
+++ crypto/bio/bss_sock.c       (revision 31832)
@@ -159,7 +159,11 @@
        if (ret <= 0)
                {
                if (BIO_sock_should_retry(ret))
-                       BIO_set_retry_write(b);
+                       if (get_last_socket_error() == EAGAIN) {
+                               get_last_socket_error() = ECONNRESET;
+                               shutdown(b->num, SHUT_WR);
+                       } else
+                               BIO_set_retry_write(b);
                }
        return(ret);
        }
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [email protected]

Reply via email to