guix-commits
[Top][All Lists]
Advanced

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

[shepherd] 04/10: shepherd: Mark client connection sockets as SOCK_NONBL


From: Ludovic Courtès
Subject: [shepherd] 04/10: shepherd: Mark client connection sockets as SOCK_NONBLOCK.
Date: Wed, 7 Sep 2022 17:19:10 -0400 (EDT)

civodul pushed a commit to branch master
in repository shepherd.

commit eb275516157f7a664844b3b657d18761932803b5
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Sep 7 12:34:45 2022 +0200

    shepherd: Mark client connection sockets as SOCK_NONBLOCK.
    
    * modules/shepherd.scm (run-daemon): Pass SOCK_NONBLOCK to 'accept'.
    * tests/misbehaved-client.sh: Add test.
---
 modules/shepherd.scm       |  2 +-
 tests/misbehaved-client.sh | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/modules/shepherd.scm b/modules/shepherd.scm
index 6e2b0a7..a6acd93 100644
--- a/modules/shepherd.scm
+++ b/modules/shepherd.scm
@@ -213,7 +213,7 @@ already ~a threads running, disabling 'signalfd' support")
 
          ;; Enter some sort of a REPL for commands.
          (let next-command ()
-           (match (accept sock SOCK_CLOEXEC)
+           (match (accept sock (logior SOCK_NONBLOCK SOCK_CLOEXEC))
              ((command-source . client-address)
               (setvbuf command-source 'block 1024)
               (spawn-fiber
diff --git a/tests/misbehaved-client.sh b/tests/misbehaved-client.sh
index 7494223..18a064f 100644
--- a/tests/misbehaved-client.sh
+++ b/tests/misbehaved-client.sh
@@ -76,4 +76,21 @@ $herd status                 # still here?
 
 $herd status
 
+"$GUILE" -c "
+(use-modules (shepherd comm) (shepherd support) (ice-9 match))
+
+(let ((sock (open-connection \"$socket\")))
+  (setvbuf sock 'none)
+  (display \"(ah ha!\" sock)
+  ;; Leave it hanging; shepherd must not block.
+  (let ((sock (open-connection \"$socket\")))
+    (write-command (shepherd-command 'status 'does-not-exist) sock)
+    (match (read sock)
+      (('reply _ ...) #t)
+      (x
+       (pk 'wrong x)
+       (exit 1)))))"
+
+$herd status
+
 cat "$log"



reply via email to

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