Subject: bug#22493: 25.1.50; open-gnutls-stream doesn't respect :nowait, so the connections are synchronous

From: Lars Ingebrigtsen <[email-masked]>
Date: Tue, 02 Feb 2016 02:43:02 +0100

Eli Zaretskii <[email-masked]> writes:

> A sentinel indeed starts when Emacs is idle, but once it kicks in, it
> runs to completion, and Emacs cannot do anything else while it does.
> So if the user presses a key a millisecond after the sentinel is
> invoked and starts the GnuTLS negotiation procedure, the user will
> still have to wait.

Sure.  But the wait is much shorter.

Anyway, the next step is, of course, to make the GnuTLS negotiation
asynchronous, too, so that the entire thing is unnoticeable.
The library itself is async, but it block because emacs_gnutls_handshake
does this:

  do
    {
      ret = gnutls_handshake (state);
      emacs_gnutls_handle_error (state, ret);
      QUIT;
    }
  while (ret < 0 && gnutls_error_is_fatal (ret) == 0);

Loop until the handshake completes.  The function should instead mark
the process' status as 'tls-handshake, return and continue the handshake
from the idle loop.

Which is something I'm not going to do straight away, because the
changes already in are complex enough.

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