Subject: bug#62990: 30.0.50; UDP server closes connection upon receiving an empty packet

From: Vasilij Schneidermann <[email-masked]>
Date: Sat, 9 Mar 2024 14:40:28 +0100

Hello again,

> Actually, it turned out to be a small change (on top of my previous
> patch)
> 
> diff --git a/src/process.c b/src/process.c
> index e3233f5ad89..eca1441062d 100644
> --- a/src/process.c
> +++ b/src/process.c
> @@ -6305,7 +6305,13 @@ read_and_dispose_of_process_output (struct Lisp_Process *p, char *chars,
>  	      coding->carryover_bytes);
>        p->decoding_carryover = coding->carryover_bytes;
>      }
> -  if (SBYTES (text) > 0)
> +  if (SBYTES (text) > 0
> +#ifdef DATAGRAM_SOCKETS
> +      || (SBYTES (text) == 0
> +	  && 0 <= p->outfd
> +	  && DATAGRAM_CHAN_P (p->outfd))
> +#endif
> +      )
>      /* FIXME: It's wrong to wrap or not based on debug-on-error, and
>         sometimes it's simply wrong to wrap (e.g. when called from
>         accept-process-output).  */

I somehow completely overlooked this second patch and can confirm that
with it, both the Emacs Lisp and Guile version of the server/client
behave identically. In other words, the UDP bug is completely fixed now.

I've done a cursory search on the web and did not find anything that
would send empty packets via UDP, so I do doubt it would break existing
code or need a opt-out setting.