David Schwartz wrote:
> Joakim Tjernlund wrote:
>
>> 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.
>
>Umm, if your code asks to wait forever until it can write, then that is what
>it should do. The fix is nonsensical.
>
>> 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:
>
>You definitely solved the problem in the wrong place. If you don't want to
>wait forever for a write to be possible, then don't do that. But if you do
>that, then that's what should happen.
>
>
>> 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);
>> }
>
>A "hung connection" *should* remain locked if the client stops reading from
>its socket. The client might continue reading from its connection in a day,
>a week, or a year. If the server wants to timeout the connection, it can and
>should do so.
Right, but I could not find how/where to do so. Can you give me some hints?
Jocke
PS.
Please keep me on CC: list
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [email protected]
Automated List Manager [email protected]