Subject: bug#22789: 25.1.50; In last master build https connections stop working

From: Alain Schneble <[email-masked]>
Date: Sun, 6 Mar 2016 23:45:49 +0100

Eli Zaretskii <[email-masked]> writes:

>> From: Alain Schneble <[email-masked]>
>> CC: <[email-masked]>, <[email-masked]>, <[email-masked]>
>> Date: Sat, 5 Mar 2016 19:27:09 +0100
>> 
>> I should have written "multiple times" not "many times".  I just had a
>> case where for four network processes (get image requests)
>> gnutls_try_handshake returned for each of these processes -28
>> GNUTLS_E_AGAIN three times in a row, followed by a single -110
>> GNUTLS_E_PREMATURE_TERMINATION and then repeatedly by -10
>> GNUTLS_E_INVALID_SESSION.
>
> Sounds like we are terminating the connection while the handshake is
> still in progress?

I'm pretty sure we are not terminating the connection prematurely.

After some more debugging, I found a way to reliably solve the issue.
It seems like switching the socket to blocking before calling send and
back to non-blocking while the socket is not connected in sys_write
somehow makes the socket unreliable.

I'll send a patch for further discussions shortly.