unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 22493@debbugs.gnu.org
Subject: bug#22493: 25.1.50; open-gnutls-stream doesn't respect :nowait, so the connections are synchronous
Date: Wed, 03 Feb 2016 17:52:54 +0200	[thread overview]
Message-ID: <83fux9yend.fsf@gnu.org> (raw)
In-Reply-To: <8760y6zha1.fsf@gnus.org> (message from Lars Ingebrigtsen on Wed,  03 Feb 2016 12:58:30 +1100)

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: 22493@debbugs.gnu.org
> Date: Wed, 03 Feb 2016 12:58:30 +1100
> 
> I think you're right again.  I thought I had tested this, but I hadn't:
> 
> (progn
>   (setq proc (make-network-process :name "foo"
>                                    :buffer (get-buffer-create "*foo*")
>                                    :host "gmane.org"
>                                    :service "http"
>                                    :nowait t))
>   (process-send-string proc "GET / HTTP/1.0\n\n"))
> 
> With async DNS, this will fail, because the process-send-string happens
> before the connection had completed.  (And this isn't a TLS socket.)  So
> I think that (like I said on the emacs-devel threads) we may have to
> change the :nowait stuff to allow a more fine-grained control.

If you make process-send-string wait until DNS completes, the problem
will disappear.  Then, if code such as above wants better async
behavior, its maintainer will have to restructure the code, for
example like this:

> So the rule would be if you want a fully async connection, you have to
> say ":nowait 'dns" or something, and then put a sentinel on the process
> to not do anything until it changes status to "connected".  (This is
> what url.el does already, which is why I didn't see this before...)

But if the code is not changed, it should still "just work", albeit
not as fast as it could.

> With a TLS socket:
> 
> make-network-process gives us a process in "open", and then when it
> changes to "connected" (after connecting the socket) we can't start
> talking.  We have to wait until the TLS has been negotiated.  So perhaps
> it should only move to the "connected" state after the negotiation has
> finished?  Or introduce more states?

Like with process-send-string, we could make gnutls-boot wait until
DNS resolution completes (and error out if DNS fails).

As for making gnutls-boot run in the background, I'm still not
convinced it buys us enough advantages (or any advantages) to justify
the changes.  Let's continue discussing that, OK?

Running gnutls-boot from a separate thread on the C level is also
possible, but AFAIU that requires a total rewrite of the current C
implementation, as it does a lot of stuff that cannot be done from a
non-main thread.

Either way, if we decide that making gnutls-boot run in the background
is a Good Thing, then I feel that doing so requires code restructuring
that must involve application-level considerations.  So these changes
probably shouldn't be done on the level of open-gnutls-stream.
Instead, we should provide the building blocks for applications that
want this, and let them restructure their code as they see fit.
Trying to do that transparently controlled by a single argument is not
going to work well, I think.





  reply	other threads:[~2016-02-03 15:52 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-30  4:00 bug#22493: 25.1.50; open-gnutls-stream doesn't respect :nowait, so the connections are synchronous Lars Ingebrigtsen
2016-01-30  4:45 ` Lars Ingebrigtsen
2016-01-30  9:21   ` Eli Zaretskii
2016-01-30 22:55     ` Lars Ingebrigtsen
2016-01-31  0:40       ` Lars Ingebrigtsen
2016-01-31  1:10         ` Lars Ingebrigtsen
2016-01-31 16:00           ` Eli Zaretskii
2016-01-31 15:59         ` Eli Zaretskii
2016-01-31 23:17           ` Lars Ingebrigtsen
2016-02-01  2:41             ` Lars Ingebrigtsen
2016-02-01  3:41             ` Eli Zaretskii
2016-02-01  4:01               ` Lars Ingebrigtsen
2016-02-01 18:50                 ` Eli Zaretskii
2016-02-02  1:43                   ` Lars Ingebrigtsen
2016-02-02 16:10                     ` Eli Zaretskii
2016-02-03  1:10                       ` Lars Ingebrigtsen
2016-02-03  1:58                         ` Lars Ingebrigtsen
2016-02-03 15:52                           ` Eli Zaretskii [this message]
2016-02-04  2:47                             ` Lars Ingebrigtsen
2016-02-04 16:39                               ` Eli Zaretskii
2016-02-05  2:36                                 ` Lars Ingebrigtsen
2016-02-05  7:24                                   ` Eli Zaretskii
2016-02-05  7:34                                     ` Lars Ingebrigtsen
2016-02-05  9:18                                       ` Eli Zaretskii
2016-02-06  3:03                                         ` Lars Ingebrigtsen
2016-02-06  7:51                                           ` Eli Zaretskii
2016-02-06  7:57                                             ` Lars Ingebrigtsen
2016-02-03 15:51                         ` Eli Zaretskii
2016-02-04  2:59                           ` Lars Ingebrigtsen
2016-01-31 15:57       ` Eli Zaretskii

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=83fux9yend.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=22493@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).