about summary refs log tree commit homepage
path: root/examples/unsubscribe-psgi@.service
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-06-30 07:11:00 +0000
committerEric Wong <e@80x24.org>2019-06-30 07:11:00 +0000
commit0ea8f5dacfb6d6bfba4dd4be86416bdd2dc5907d (patch)
treec405fc00e790c8bdc90b1b94b24c7c03dca8e3a9 /examples/unsubscribe-psgi@.service
parent97c346050509758b5d5152f6ff1e0b0f8d871954 (diff)
downloadpublic-inbox-0ea8f5dacfb6d6bfba4dd4be86416bdd2dc5907d.tar.gz
For users running multiple (-nntpd@1, -nntpd@2) instances of
either -httpd or -nntpd via systemd to implement zero-downtime
restarts; it's possible for a listen socket to become blocking
for a moment during an accept syscall and cause a daemons to
get stuck in a blocking accept() during
PublicInbox::Listener::event_step (event_read in previous
versions).

Since O_NONBLOCK is a file description flag, systemd clearing
O_NONBLOCK momentarily (before PublicInbox::Listener::new
re-enables it) creates a window for another instance of our
daemon to get stuck in accept().

cf. systemd.service(5)
Diffstat (limited to 'examples/unsubscribe-psgi@.service')
-rw-r--r--examples/unsubscribe-psgi@.service5
1 files changed, 5 insertions, 0 deletions
diff --git a/examples/unsubscribe-psgi@.service b/examples/unsubscribe-psgi@.service
index acc29e8e..c8721fbe 100644
--- a/examples/unsubscribe-psgi@.service
+++ b/examples/unsubscribe-psgi@.service
@@ -12,7 +12,12 @@ After = unsubscribe-psgi.socket
 # any PSGI server ought to work,
 # but public-inbox-httpd supports socket activation like unsubscribe.milter
 ExecStart = /usr/local/bin/public-inbox-httpd -W0 /etc/unsubscribe.psgi
+
+# NonBlocking is REQUIRED to avoid a race condition if running
+# simultaneous services
+NonBlocking = true
 Sockets = unsubscribe-psgi.socket
+
 # we need to modify the mlmmj spool
 User = mlmmj
 KillMode = process