unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 49449@debbugs.gnu.org, larsi@gnus.org
Subject: bug#49449: 28: TLS connection never gets to "open" stage
Date: Sun, 11 Jul 2021 16:26:47 +0200	[thread overview]
Message-ID: <A72820CE-5C39-46B0-B1AE-EEA467356E5A@acm.org> (raw)
In-Reply-To: <83eec5b1jb.fsf@gnu.org>

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

11 juli 2021 kl. 12.14 skrev Eli Zaretskii <eliz@gnu.org>:

> Did you succeed in understanding what else has to happen before that
> flag could be safely reset?

Yes. The TCP connection needs to be established, the socket descriptor removed from write monitoring (because it is now connected) and added to read monitoring (so that we can get incoming traffic).

This suggests a second solution: remove the condition on line 3277 on the grounds that since the TLS handshake succeeded, we are evidently connected; then remove the write monitoring and add the read monitoring before calling the sentinel:


[-- Attachment #2: alt.diff --]
[-- Type: application/octet-stream, Size: 649 bytes --]

diff --git a/src/process.c b/src/process.c
index b8c3e4ecfb..7d2a9e9a62 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3274,8 +3274,13 @@ finish_after_tls_connection (Lisp_Object proc)
       pset_status (p, Qfailed);
       deactivate_process (proc);
     }
-  else if ((fd_callback_info[p->outfd].flags & NON_BLOCKING_CONNECT_FD) == 0)
+  else
     {
+      delete_write_fd (p->outfd);
+
+      if (0 <= p->infd && !EQ (p->filter, Qt) && !EQ (p->command, Qt))
+	add_process_read_fd (p->infd);
+
       /* If we cleared the connection wait mask before we did the TLS
 	 setup, then we have to say that the process is finally "open"
 	 here. */

[-- Attachment #3: Type: text/plain, Size: 992 bytes --]


> And anyway, if those conditions are not yet set, I wonder why are we
> calling finish_after_tls_connection at that place?

There's no harm in calling `gnutls_handshake`; it will just return E_AGAIN if the connection hasn't been established. On the other hand there's little point in doing so until we have a connection.

Which suggests a third solution: do the handshake right away after establishing the connection. That would go into the code somewhere before line 5900, which right now is a condition that I don't quite understand. I think Lars wrote it but apparently forgot all about it (happens to everyone once in a while).

I still favour the less intrusive patch posted previously (adding a condition at line 5235) since it avoids duplication; there is already far too much of that in the code (everything seems to be done in at least two places). The code is obviously in the need of restructuring, but we shouldn't conflate that effort with fixing this specific bug.


  reply	other threads:[~2021-07-11 14:26 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
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 [this message]
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=A72820CE-5C39-46B0-B1AE-EEA467356E5A@acm.org \
    --to=mattiase@acm.org \
    --cc=49449@debbugs.gnu.org \
    --cc=eliz@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).