]> Sergey Matveev's repositories - public-inbox.git/commitdiff
examples/*@.service: sockets MUST be NonBlocking
authorEric Wong <e@80x24.org>
Sun, 30 Jun 2019 07:11:00 +0000 (07:11 +0000)
committerEric Wong <e@80x24.org>
Sun, 30 Jun 2019 07:11:00 +0000 (07:11 +0000)
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)

examples/public-inbox-httpd@.service
examples/public-inbox-nntpd@.service
examples/unsubscribe-psgi@.service

index 56117ef09368405ac21683d62b33d14edfda0c63..e811da40497a402e88f1b58a614a8519e7980434 100644 (file)
@@ -20,7 +20,12 @@ ExecStartPre = /bin/mkdir -p -m 1777 /tmp/.pub-inline
 ExecStart = /usr/local/bin/public-inbox-httpd \
 -1 /var/log/public-inbox/httpd.out.log
 StandardError = syslog
+
+# NonBlocking is REQUIRED to avoid a race condition if running
+# simultaneous services
+NonBlocking = true
 Sockets = public-inbox-httpd.socket
+
 KillSignal = SIGQUIT
 User = nobody
 Group = nogroup
index 62202c2fa54e18a9f11da0fe0540f2c904a23864..a879841e6dacde6096c89d666547370cd150f4fe 100644 (file)
@@ -20,7 +20,12 @@ ExecStartPre = /bin/mkdir -p -m 1777 /tmp/.pub-inline
 ExecStart = /usr/local/bin/public-inbox-nntpd \
 -1 /var/log/public-inbox/nntpd.out.log
 StandardError = syslog
+
+# NonBlocking is REQUIRED to avoid a race condition if running
+# simultaneous services
+NonBlocking = true
 Sockets = public-inbox-nntpd.socket
+
 KillSignal = SIGQUIT
 User = nobody
 Group = nogroup
index acc29e8e64c648a448ac4433fd587a17da561f78..c8721fbe1d1bee5247ad721e656a5524dace2a72 100644 (file)
@@ -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