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

From: Lars Ingebrigtsen <[email-masked]>
Date: Sat, 27 Feb 2016 14:19:08 +1030

Lars Ingebrigtsen <[email-masked]> writes:

> So deferring setting g->gnutls_p is not a good idea.  I'll try to debug
> this further, but may not have time today...

Hey!  Time!

The following patch should make the rest of Emacs leave the TLS socket
alone until we've done the handshake, I think.  It works for me under
Linux (and makes the negotiation blocking).  Could you test this under
Windows?

diff --git a/src/gnutls.c b/src/gnutls.c
index d1b34c5..002e7b4 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -403,6 +403,9 @@ gnutls_try_handshake (struct Lisp_Process *proc)
   gnutls_session_t state = proc->gnutls_state;
   int ret;
 
+  if (proc->is_non_blocking_client)
+    proc->gnutls_p = true;
+
   do
     {
       ret = gnutls_handshake (state);
@@ -410,13 +413,13 @@ gnutls_try_handshake (struct Lisp_Process *proc)
       QUIT;
     }
   while (ret < 0 && gnutls_error_is_fatal (ret) == 0
-	 && ! proc->is_non_blocking_client);
+#if 0
+	 && ! proc->is_non_blocking_client
+#endif
+	 );
 
   proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
 
-  if (proc->is_non_blocking_client)
-    proc->gnutls_p = true;
-
   if (ret == GNUTLS_E_SUCCESS)
     {
       /* Here we're finally done.  */

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no