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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 05 Mar 2016 10:23:25 +0200

> From: Alain Schneble <[email-masked]>
> CC: <[email-masked]>, <[email-masked]>, <[email-masked]>
> Date: Fri, 4 Mar 2016 22:36:56 +0100
> 
> I have the impression that GnuTLS doesn't like it too much if we start
> retrying the handshake many times before the socket is connected.  At
> least on MS-Windows.  In nearly all of the cases of loading websites
> with around 20 images, I observe arbitrary failures of
> gnutls_try_handshake which usually end up with -10
> GNUTLS_E_INVALID_SESSION.

I think this warrants a question to GnuTLS developers.  We need to
understand this before we devise a solution.  What bothers me is the
"many times" part -- how many is "too much", and why?  Do you see any
difference in behavior of sys_write during those many attempts as
opposed to the first few?

Also, what URL do you use for testing this?

> I believe this because the following patch solves the issue on my
> MS-Windows system: Postponing the handshake until after the socket is
> connected.  Still, I must be honest: I'm in a kind of a trial-and-error
> mode.  I do not really understand all the aspects of the current
> implementation.

Feel free to ask, I think I can answer any question about the Emacs
part of this, but probably not about the GnuTLS part -- those we
should ask on the GnuTLS mailing list.

> Anyway, I think a change in that direction would
> probably be a good thing.  Do you agree?  It eliminates all the
> handshake-retries that would otherwise happen before the socket is
> connected.

Why is it needed only on Windows?  Why does it matter what reason
causes the failure of a handshake?  We need to understand these
aspects before we consider the solutions.

> BTW, `libgnutls-version' evaluates to 30408 on my MS-Windows.

It's 30311 here, but I'm not sure this is a factor.  We are talking
about basic functionality here.

Thanks.