From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#62990: 30.0.50; UDP server closes connection upon receiving an empty packet Date: Tue, 25 Apr 2023 10:07:59 +0200 Message-ID: <87ttx49yg0.fsf@gmail.com> References: <87wn21br45.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33227"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62990@debbugs.gnu.org To: Vasilij Schneidermann Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 25 10:09:15 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1prDje-0008Rn-MX for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 25 Apr 2023 10:09:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1prDjV-0004oR-1N; Tue, 25 Apr 2023 04:09:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1prDjT-0004oI-EU for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2023 04:09:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1prDjS-00024k-Ny for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2023 04:09:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1prDjS-0003ek-Jf for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2023 04:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 25 Apr 2023 08:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62990 X-GNU-PR-Package: emacs Original-Received: via spool by 62990-submit@debbugs.gnu.org id=B62990.168241009013996 (code B ref 62990); Tue, 25 Apr 2023 08:09:02 +0000 Original-Received: (at 62990) by debbugs.gnu.org; 25 Apr 2023 08:08:10 +0000 Original-Received: from localhost ([127.0.0.1]:51194 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prDic-0003df-4a for submit@debbugs.gnu.org; Tue, 25 Apr 2023 04:08:10 -0400 Original-Received: from mail-wm1-f44.google.com ([209.85.128.44]:48396) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1prDia-0003dS-7H for 62990@debbugs.gnu.org; Tue, 25 Apr 2023 04:08:08 -0400 Original-Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-3f1738d0d4cso34697195e9.1 for <62990@debbugs.gnu.org>; Tue, 25 Apr 2023 01:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682410081; x=1685002081; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=WXNf2IpJNdLvCXQ0oCFVjb0hOaIzVWNzE/FfSwj+/fU=; b=nSCF6eP1HyUKlmczZXnr10lBLJULZfe9/cePVTEu8rgjelR1GrK0Z+7eAxeKh6KhsA oxQBqT83Zhn24tkWfN7K+XWbHCnBSonBKzuZP4xdnySDaqLUiuKcz6411n+xSXyxMcaU 7/IG5n4+cQ3IEUzcA6gYolm+W0peWD65eiKOc7S6BOcvEuCKlNDLyUYKMNQENnPYQ6VF ln9PnBCCREcBZVgvza0pyP3CSdhGHQi3K0ct8iRwd+FjpvpMXHM+CTg1hRg9l/Aah6Ci YU53yEeti/1gXrNAtjQuPdEqWBlATynJ7RYcsOwmnbdoVa3kyWWPI2Fijb1IJze3ZGcb BlUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682410081; x=1685002081; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WXNf2IpJNdLvCXQ0oCFVjb0hOaIzVWNzE/FfSwj+/fU=; b=FpXDE425bXqdp7M+YHOO0cmbA6kXeexdUKPKCu1JocbasnzhB0UszBbNDOCH4TfVdy jPqGPkKHAHmr654E/5kDYI9q77l4cHhH2r6F+4T1kPkDXNyePhKgZr+ki/xpKdPbAgCy nqM7m3FRTBdkMW9ZIKrBfa8N+OdZFPS+uqoCxyTN6hjeysi8WwwJFqCD2WidyWyNeBUM lcsravM82UdLcKEjsO+ndE0RPzUTuodlxAmign0Sv8f67MggGBhVTQZfsUNFADPLuUG4 y8JULZZSPE7FiKsErMHTgKm52myay/xaDFnFrWNe53R/R3V/jhPooVdTAs5c/qA3dPiA Aszw== X-Gm-Message-State: AAQBX9f5L0QgXv0NH6SMzn7Ig7QF83JPbdfUvVoUQe2p/bgCw+eizZps MQ1TIN0M6cGmM0G8khjr4/mvtS4uPK0= X-Google-Smtp-Source: AKy350bBxd/1UHCrqcvQr2jkoGEJDwTKRxT6a9X7x6cWLD2eose+PYLjxpUeI94Zq9dVHXIAnew+lw== X-Received: by 2002:a05:600c:22d4:b0:3f1:82c6:2d80 with SMTP id 20-20020a05600c22d400b003f182c62d80mr10009617wmg.5.1682410081380; Tue, 25 Apr 2023 01:08:01 -0700 (PDT) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id g9-20020a05600c000900b003f0aa490336sm17491197wmc.26.2023.04.25.01.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Apr 2023 01:08:00 -0700 (PDT) In-Reply-To: (Vasilij Schneidermann's message of "Mon, 24 Apr 2023 23:04:34 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:260603 Archived-At: >>>>> On Mon, 24 Apr 2023 23:04:34 +0200, Vasilij Schneidermann said: >> Empty TCP messages are perfectly valid, but they should be hidden fr= om >> you. recvfrom returning 0 means the connection has been closed, but >> that=CA=BCs a separate thing. Vasilij> I suspect there's a missing ifdef in the code which ends up te= rminating Vasilij> the process on such a condition, for both TCP and UDP. Yes, although in a different place than I expected. Patch below. The end result is to ignore the zero length message, getting it delivered to the process would involve considerably bigger changes. >> Could you show how you=CA=BCre generating the empty packets? Vasilij> Download the attachments from my previous email, launch the se= rver with Vasilij> `emacs --batch -l bug-server.el`, then the client with `guile Vasilij> fixed-client.scm`. Swap out the server with `guile fixed-serve= r.scm`. I was hoping to avoid installing guile :-) The client works, but the server gets me this, which means I=CA=BCm missing some bits somewhere: Backtrace: 6 (primitive-load "/home/rpluim/repos/fixed-server.scm") In ice-9/eval.scm: 721:20 5 (primitive-eval (import (rnrs bytevectors gnu))) In ice-9/psyntax.scm: 1241:36 4 (expand-top-sequence ((import (rnrs bytevectors gnu))) _ = =E2=80=A6) 1233:19 3 (parse _ (("placeholder" placeholder)) ((top) #(# # =E2=80= =A6)) =E2=80=A6) 285:10 2 (parse _ (("placeholder" placeholder)) (()) _ c&e (eval) = =E2=80=A6) In ice-9/eval.scm: 293:34 1 (_ #) In ice-9/boot-9.scm: 3300:6 0 (resolve-interface (rnrs bytevectors gnu) #:select _ # _ = =E2=80=A6) ice-9/boot-9.scm:3300:6: In procedure resolve-interface: no code for module (rnrs bytevectors gnu) Does guile deliver the empty message? >> It=CA=BCs allowed by the protocol. I guess it could be useful for pe= ople >> wanting to implement their own keep-alive protocol over UDP. Vasilij> I think so as well. I=CA=BCll look into it. I suspect it won=CA=BCt be a small change. Robert --=20 diff --git a/src/process.c b/src/process.c index 8e467ff7511..babe926ca5b 100644 --- a/src/process.c +++ b/src/process.c @@ -5947,6 +5947,11 @@ wait_reading_process_output (intmax_t time_limit, in= t nsecs, int read_kbd, #endif /* HAVE_PTYS */ /* If we can detect process termination, don't consider the process gone just because its pipe is closed. */ +#ifdef DATAGRAM_SOCKETS + /* A zero byte read on a UDP socket is not an error. */ + else if (nread =3D=3D 0 && DATAGRAM_CHAN_P (channel)) + ; +#endif else if (nread =3D=3D 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc) && !PIPECONN_P (proc)) ;