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

From: Alain Schneble <[email-masked]>
Date: Mon, 7 Mar 2016 17:47:43 +0100

Eli Zaretskii <[email-masked]> writes:

>> From: Alain Schneble <[email-masked]>
>> CC: <[email-masked]>, <[email-masked]>, <[email-masked]>
>> Date: Mon, 7 Mar 2016 00:24:35 +0100
>> 
>> > I'll send a patch for further discussions shortly.
>> 
>> And here it is.  The fix is quite simple.  It ensures that sys_write
>> exits before touching the socket if it is not connected yet.
>> Unfortunately I didn't find any documentation on winsock ioctlsocket
>> that would prove that this is indeed required.  But it seems not wrong
>> to me anyway.  (I'll try to search the wisock documentation tomorrow to
>> find some hints that lead in this direction, or maybe you know?)
>
> I think this change should be installed regardless, as it fixes an
> oversight.  However, I think it needs to be augmented, because the
> fact that FILE_CONNECT flag is set doesn't necessarily mean the
> connection is in progress: it could have failed already.  We need to
> look at the status as well.

Thank you.  I'll study the state table later...

> So we should only return EWOULDBLOCK when FILE_CONNECT is set _and_
> the status is not STATUS_CONNECT_FAILED.  If FILE_CONNECT is set, but
> the status is STATUS_CONNECT_FAILED, we should instead return the
> value computed from cp->errcode (if it is non-zero).  There's an
> example of that in sys_read.

Ok, thanks for this information.  I'll read through that code once
again...

> Other than that, what specific problem does your change try or is
> known to solve?  IOW, what didn't work before the change, and works
> after it?

Aha.  Sorry, I was not clear about that.

It fixes all the reproducible issues I had when "asynchronously" loading
a website with images in eww on MS-Windows
(e.g. https://www.microsoft.com).  gnutls_handshake returned with
arbitrary failures when loading the images.  It returned with errors -15
GNUTLS_E_UNEXPECTED_PACKET or -110 GNUTLS_E_PREMATURE_TERMINATION,
followed by -10 GNUTLS_E_INVALID_SESSION.  It happend all the time, but
arbitrarily only for some of the images.  The affected images were not
downloaded and displayed in eww at all because the GnuTLS session could
not be established.