unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 49449@debbugs.gnu.org
Subject: bug#49449: 28: TLS connection never gets to "open" stage
Date: Thu, 8 Jul 2021 18:47:11 +0200	[thread overview]
Message-ID: <E3A62152-0EC5-49C9-8036-3B87B9CAD951@acm.org> (raw)
In-Reply-To: <87o8bdt180.fsf@gnus.org>

[-- Attachment #1: Type: text/plain, Size: 434 bytes --]

8 juli 2021 kl. 14.54 skrev Lars Ingebrigtsen <larsi@gnus.org>:

> Sorry, nope.  :-/

I was thinking about 9c74f2fea6bf which introduced the condition of the wait mask, and maybe ac6e085cf6b2 where async TLS negotiation was added.

A hack like the one below would "solve" the problem by pretending that the first handshake attempt always fails with E_AGAIN, but it would be better to do it in a slightly more principled way.


[-- Attachment #2: tls-handshake-hack.diff --]
[-- Type: application/octet-stream, Size: 984 bytes --]

diff --git a/src/gnutls.c b/src/gnutls.c
index 22e7f2cbc1..47ac679c5c 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -623,13 +623,23 @@ gnutls_try_handshake (struct Lisp_Process *proc)
   if (non_blocking)
     proc->gnutls_p = true;
 
-  while ((ret = gnutls_handshake (state)) < 0)
+  if (non_blocking && proc->gnutls_handshakes_tried < 1)
     {
-      if (emacs_gnutls_handle_error (state, ret) == 0) /* fatal */
-	break;
+      /* HACK: don't succeed the first time for nonblocking connections,
+	 because the logic doesn't allow it (bug#49449).  */
+      ret = GNUTLS_E_AGAIN;
       maybe_quit ();
-      if (non_blocking && ret != GNUTLS_E_INTERRUPTED)
-	break;
+    }
+  else
+    {
+      while ((ret = gnutls_handshake (state)) < 0)
+	{
+	  if (emacs_gnutls_handle_error (state, ret) == 0) /* fatal */
+	    break;
+	  maybe_quit ();
+	  if (non_blocking && ret != GNUTLS_E_INTERRUPTED)
+	    break;
+	}
     }
 
   proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;

  reply	other threads:[~2021-07-08 16:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06 19:12 bug#49449: 28: TLS connection never gets to "open" stage Mattias Engdegård
2021-07-07 19:57 ` Lars Ingebrigtsen
2021-07-08  7:59   ` Mattias Engdegård
2021-07-08 12:54     ` Lars Ingebrigtsen
2021-07-08 16:47       ` Mattias Engdegård [this message]
2021-07-10 16:27         ` Lars Ingebrigtsen
2021-07-10 16:51           ` Mattias Engdegård
2021-07-10 16:57             ` Lars Ingebrigtsen
2021-07-10 17:07               ` Mattias Engdegård
2021-07-10 18:23               ` Mattias Engdegård
2021-07-10 18:54                 ` Eli Zaretskii
2021-07-10 19:22                   ` Mattias Engdegård
2021-07-10 19:31                     ` Eli Zaretskii
2021-07-10 19:44                       ` Mattias Engdegård
2021-07-11  6:49                         ` Eli Zaretskii
2021-07-11  7:42                           ` Mattias Engdegård
2021-07-11 10:14                             ` Eli Zaretskii
2021-07-11 14:26                               ` Mattias Engdegård
2021-07-11 15:01                                 ` Eli Zaretskii
2021-07-12 14:57                                   ` Mattias Engdegård
2021-07-12 15:02                                     ` Lars Ingebrigtsen
2021-07-13 17:08                                       ` Mattias Engdegård
2021-07-10 20:05                 ` Mattias Engdegård
2021-07-11 11:31                   ` Lars Ingebrigtsen
2021-07-11 11:29                 ` Lars Ingebrigtsen
2021-07-11 14:28                   ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E3A62152-0EC5-49C9-8036-3B87B9CAD951@acm.org \
    --to=mattiase@acm.org \
    --cc=49449@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).