guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[shepherd] 05/06: service: inetd: Clear O_NONBLOCK on the connection soc


From: Ludovic Courtès
Subject: [shepherd] 05/06: service: inetd: Clear O_NONBLOCK on the connection socket.
Date: Mon, 1 Jan 2024 17:38:53 -0500 (EST)

civodul pushed a commit to branch main
in repository shepherd.

commit 2563bc01bec1a4b1e1c4d9be2e603b22a83aa171
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Jan 1 23:33:07 2024 +0100

    service: inetd: Clear O_NONBLOCK on the connection socket.
    
    Fixes a portability issue for GNU/Hurd.
    
    * modules/shepherd/service.scm (make-inetd-constructor): Add ‘fcntl’
    calls before calling ‘spawn-child-service’.
---
 modules/shepherd/service.scm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 2b8c025..8eac844 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -2088,6 +2088,14 @@ rejecting connection from ~:[~a~;~*local process~].")
                   (socket-address->string server-address)
                   (= AF_UNIX (sockaddr:fam client-address))
                   (socket-address->string client-address))
+
+                 ;; On the Hurd, the file descriptor returned by 'accept4'
+                 ;; inherits O_NONBLOCK from SOCK.  Clear it so the server
+                 ;; gets a blocking socket (it doesn't hurt on Linux).
+                 (fcntl connection F_SETFL
+                        (logand (fcntl connection F_GETFL)
+                                (lognot O_NONBLOCK)))
+
                  (spawn-child-service connection
                                       server-address client-address)))))
         (loop))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]