bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#22493: 25.1.50; open-gnutls-stream doesn't respect :nowait, so the c


From: Lars Ingebrigtsen
Subject: bug#22493: 25.1.50; open-gnutls-stream doesn't respect :nowait, so the connections are synchronous
Date: Wed, 03 Feb 2016 12:58:30 +1100
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.1.50 (gnu/linux)

Lars Ingebrigtsen <larsi@gnus.org> writes:

>>   +#ifdef HAVE_GNUTLS
>>   +  /* The TLS connection hasn't been set up yet, so we can't write
>>   +     anything on the socket. */
>>   +  if (!NILP (p->gnutls_boot_parameters))
>>   +    return;
>>   +#endif
>>
>> I don't think this is a good idea: you are silently returning here
>> without doing anything; the callers of send_process won't expect
>> that.  I think this should signal an error instead.
>
> It's perfectly fine to say
>
> (setq proc (make-network-process ... :nowait t :tls-parameters ...))
> (process-send-string proc)

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.

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 in the case of TLS connections, then, er, we have to ... do
something.

Ok, here's the scenario.  With a non-TLS socket, this is what's going
on:

make-network-process gives us a process in "open", and then when it
changes to "connected" (after connecting the socket) we can start
talking.  (This is what url.el does.)

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?

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]