]> git.eshelyaron.com Git - emacs.git/commit
Block TLS handshake until TCP connection established
authorMattias Engdegård <mattiase@acm.org>
Mon, 12 Jul 2021 11:58:28 +0000 (13:58 +0200)
committerMattias Engdegård <mattiase@acm.org>
Tue, 13 Jul 2021 17:07:41 +0000 (19:07 +0200)
commit7a803ecd3d455999cfc9266fa219d58109fac786
treee24f82c78991b57c2144240a2d831833e240ae60
parenta41f585bf111b239601ca7d915994fed600852af
Block TLS handshake until TCP connection established

If a TLS handshake is attempted before the completion of an
asynchronous TCP connection has been ascertained, our local state will
not be set up correctly for further progress and the sentinel "open"
event will never be sent.  This can occur if sufficient time passes
after the initiation of an async TCP connection so that by the time
`wait_reading_process_output` is called, the connection has already
been established on the TCP level.

This somewhat timing-sensitive bug has plagued HTTPS connections on
some platforms, notably macOS, for a long time (bug#49449).

* src/process.c (wait_reading_process_output): Gate the TLS handshake
by the NON_BLOCKING_CONNECT_FD flag.  The flag will be cleared as soon
as the TCP socket is found to be writable.
* test/src/process-tests.el (process-async-https-with-delay):
New test.
src/process.c
test/src/process-tests.el