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

From: Robert Pluim <[email-masked]>
Date: Wed, 26 Apr 2023 16:31:54 +0200

>>>>> On Wed, 26 Apr 2023 13:50:17 +0200, Robert Pluim <[email-masked]> said:

>>>>> On Wed, 26 Apr 2023 12:56:39 +0200, Vasilij Schneidermann <[email-masked]> said:
    Vasilij> Thank you. Yes, that is the case, the network process is no longer shut
    Vasilij> down, but the 0-length message isn't picked up. It prints the following:

    Vasilij> Received string (5): "hello"
    Vasilij> Received string (5): "world"

    Vasilij> Rather than the expected:

    Vasilij> Received string (5): "hello"
    Vasilij> Received string (0): ""
    Vasilij> Received string (5): "world"

    Robert> Right. Getting emacs to deliver a zero length string to the UDP
    Robert> process would be quite a change, one I canʼt get to any time soon.

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).  */

Robert
--