Subject: Re: bug#77610: guix-daemon socket activation does not work on the hurd

From: [email-masked]
Date: Thu, 15 May 2025 10:18:38 +0200 (CEST)

Hello Ludo,

Something like this? I called the patch hurd-socket-activation.patch to indicate what it is addressing. Do you have a better suggestion?

I added it to master but this will create a minor merge conflict with the hurd update on core-packages-team.

May 14, 2025, 21:51 by [email-masked]:

> Hi yelninei,
>
> [email-masked] writes:
>
>> Thank you again for finding the cause.Could we add your patch to our
>> hurd either for master or core-packages-team as it will be a while
>> until it is available in a tagged snapshot.It would fix the hurd ci
>> builders randomly failing, the childhurd system test and the minor
>> annoyance that the manual offload is failing.
>>
>> From what I can see only adding it to hurd (and not the headers) should not cause a rebootstrap. 
>>
>
> Yes, sounds like a good idea.  Do you want to give it a try?
>
> Thanks,
> Ludo’.
>

>From 9119ca37613df139db80e36b821a54c137a56037 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
From: Yelninei <[email-masked]>
Date: Thu, 15 May 2025 07:51:43 +0000
Subject: [PATCH] gnu: hurd: Fix service socket activation.

Fixes https://issues.guix.gnu.org/77610.

* gnu/packages/patches/hurd-socket-activation.patch: New patch
* gnu/packages/hurd.scm (hurd): Add it.
* gnu/local.mk: Register it.

Change-Id: Iff7f30099ffeb014aaacdc3a19bd7930795904b6
---
 gnu/local.mk                                  |  1 +
 gnu/packages/hurd.scm                         |  1 +
 .../patches/hurd-socket-activation.patch      | 44 +++++++++++++++++++
 3 files changed, 46 insertions(+)
 create mode 100644 gnu/packages/patches/hurd-socket-activation.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index dfafe8b8953..5dc3be1927f 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1591,6 +1591,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/hurd-64bit.patch				\
   %D%/packages/patches/hurd-refcounts-assert.patch		\
   %D%/packages/patches/hurd-rumpdisk-no-hd.patch		\
+  %D%/packages/patches/hurd-socket-activation.patch		\
   %D%/packages/patches/hurd-startup.patch			\
   %D%/packages/patches/hwloc-1-test-btrfs.patch			\
   %D%/packages/patches/i7z-gcc-10.patch				\
diff --git a/gnu/packages/hurd.scm b/gnu/packages/hurd.scm
index 3b02ed00d1a..443001fbb7b 100644
--- a/gnu/packages/hurd.scm
+++ b/gnu/packages/hurd.scm
@@ -319,6 +319,7 @@ (define-public hurd
               (patches (search-patches "hurd-refcounts-assert.patch"
                                        "hurd-rumpdisk-no-hd.patch"
                                        "hurd-startup.patch"
+                                       "hurd-socket-activation.patch"
                                        "hurd-64bit.patch"))))
     (version (package-version hurd-headers))
     (arguments
diff --git a/gnu/packages/patches/hurd-socket-activation.patch b/gnu/packages/patches/hurd-socket-activation.patch
new file mode 100644
index 00000000000..e204a90d3aa
--- /dev/null
+++ b/gnu/packages/patches/hurd-socket-activation.patch
@@ -0,0 +1,44 @@
+From 029ab7d7b38c76ba14c24fcbf526ccef29af9e88 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <[email-masked]>
+Date: Thu, 8 May 2025 23:11:36 +0200
+Subject: pflocal: Do not inherit PFLOCAL_SOCK_NONBLOCK across connect/accept.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Previously, ‘accept’ would return an O_NONBLOCK socket if the listening
+socket was O_NONBLOCK at the time the connection was made.  With this
+change, ‘accept’ always returns a socket where O_NONBLOCK is cleared.
+---
+ pflocal/sock.c | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/pflocal/sock.c b/pflocal/sock.c
+index 90c618e..6bc061d 100644
+--- a/pflocal/sock.c
++++ b/pflocal/sock.c
+@@ -1,6 +1,6 @@
+ /* Sock functions
+ 
+-   Copyright (C) 1995,96,2000,01,02, 2005 Free Software Foundation, Inc.
++   Copyright (C) 1995,96,2000,01,02, 2005, 2025 Free Software Foundation, Inc.
+    Written by Miles Bader <[email-masked]>
+ 
+    This program is free software; you can redistribute it and/or
+@@ -167,8 +167,11 @@ sock_clone (struct sock *template, struct sock **sock)
+   if (err)
+     return err;
+ 
+-  /* Copy some properties from TEMPLATE.  */
+-  (*sock)->flags = template->flags & ~PFLOCAL_SOCK_CONNECTED;
++  /* Copy some properties from TEMPLATE.  Clear O_NONBLOCK because the socket
++     returned by 'accept' must not inherit O_NONBLOCK from the parent
++     socket.  */
++  (*sock)->flags =
++    template->flags & ~(PFLOCAL_SOCK_CONNECTED | PFLOCAL_SOCK_NONBLOCK);
+ 
+   return 0;
+ }
+-- 
+cgit v1.1
+

base-commit: 7b73f02c38d568147f1b6a7ff4467f73a212cd1e
-- 
2.49.0