From 84207df87dc9ed6b26f3851551dc5b6883fe44f0 Mon Sep 17 00:00:00 2001 From: Puck Meerburg Date: Wed, 9 Oct 2024 20:36:44 +0000 Subject: [PATCH] aux/socket: patch scheduling bug in socket egg It's possible for the thread to be interrupted between configuring the timeout and the file descriptor wait. This causes a low-probability 60 second wait until the timeout expires. Now that this is fixed, we can set a normal timeout on the socket once again, so do that. Link: https://github.com/ursetto/socket-egg/pull/7 --- aux/overlay.nix | 3 ++- aux/socket.diff | 21 +++++++++++++++++++++ core/src/magic.sld | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 aux/socket.diff diff --git a/aux/overlay.nix b/aux/overlay.nix index 953c244..5075911 100644 --- a/aux/overlay.nix +++ b/aux/overlay.nix @@ -7,7 +7,8 @@ _: prevpkgs: { socket = preveggs.socket.overrideAttrs (o: { preBuild = null; - postPatch = "echo 'touch socket-config' >> build-socket-config"; + patches = (o.patches or []) ++ [ ./socket.diff ]; + postPatch = null; }); }); }); diff --git a/aux/socket.diff b/aux/socket.diff new file mode 100644 index 0000000..452a1a8 --- /dev/null +++ b/aux/socket.diff @@ -0,0 +1,21 @@ +diff --git a/build-socket-config b/build-socket-config +index 7061553..a9b120f 100755 +--- a/build-socket-config ++++ b/build-socket-config +@@ -3,3 +3,4 @@ + echo "(import scheme)" > socket-config.scm + echo "(import (chicken platform))" >> socket-config.scm + ./socket-features >> socket-config.scm ++touch socket-config +diff --git a/socket.egg b/socket.egg +index 70c3b56..fa876f3 100644 +--- a/socket.egg ++++ b/socket.egg +@@ -13,6 +13,7 @@ + (source-dependencies "socket.scm") + (component-dependencies socket-config) + (csc-options "-O2" "-d1" ++ "-disable-interrupts" + "-X" "socket-config" + "-X" "feature-test-syntax" + "-D" "scan-buffer-line-returns-3-vals"))) diff --git a/core/src/magic.sld b/core/src/magic.sld index 639954a..5c1a909 100644 --- a/core/src/magic.sld +++ b/core/src/magic.sld @@ -27,7 +27,7 @@ (define *daemon* (make-parameter (parameterize - ((socket-send-buffer-size 4096) (socket-send-size 4096) (socket-receive-timeout #f) (socket-send-timeout #f)) + ((socket-send-buffer-size 4096) (socket-send-size 4096) (socket-receive-timeout 5000) (socket-send-timeout 5000)) (let ((unix-socket (socket af/unix sock/stream))) (socket-connect unix-socket (unix-address "/nix/var/nix/daemon-socket/socket")) (let-values (((in-port out-port) (socket-i/o-ports unix-socket)))