Subject: Re: bug#45821: Emacs UDP support on Windows

From: Eli Zaretskii <[email-masked]>
Date: Mon, 02 Jan 2023 15:38:24 +0200

> From: Robert Pluim <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Mon, 02 Jan 2023 14:29:50 +0100
> 
> >>>>> On Mon, 02 Jan 2023 14:41:00 +0200, Eli Zaretskii <[email-masked]> said:
> 
>     >> Cc: "[email-masked]" <[email-masked]>
>     >> From: Robert Pluim <[email-masked]>
>     >> Date: Mon, 02 Jan 2023 11:22:03 +0100
>     >> 
>     Alex> ❌ Indeed, TLS is broken -> Eww to
>     >> https://www.gnu.org<https://www.gnu.org/> fails to load the page (
>     >> see attached image – Emacs instance on the left, compiled with UDP
>     >> patch, didn’t load gnu.org while on the right side- default Emacs
>     >> build for 28.1 opens it without any issues)
>     >> 
>     >> Yep. Last time I looked at this, the TLS handshaking fails to complete
>     >> (see src/process.c around line 5329 and the checking against
>     >> GNUTLS_EMACS_HANDSHAKES_LIMIT) which means weʼre continually retrying
>     >> the handshake without giving the remote end a chance to send us
>     >> anything. Which I think means that our state machine for TLS
>     >> negotiation is subtly incorrect, but only on MS-Windows.
> 
>     Eli> On MS-Windows, there's another state machine involved, the one
>     Eli> vis-a-vis the reader thread we start to read the stuff from the
>     Eli> network connection.  See reader_thread and sys_select in w32proc.c and
>     Eli> sys_write, sys_read, _sys_read_ahead, _sys_wait_accept, and
>     Eli> _sys_wait_connect in w32.c.
> 
> Hmm, in that case I then suspect that `sys_select' is indicating that
> the socket it connected even when it isnʼt.

If that is the case, maybe we lack some flag(s) in the filedesc
structure.