From d7fda3f4b9d4c9e6d01c818f09905d6827fa693f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 22 Mar 2020 08:58:48 +0000 Subject: daemon: fix SIGUSR2 upgrade with -W0 (no workers) Disabling workers via `-W0' blesses the contents of the @listeners array, so we need to ensure we call fcntl on the GLOB ref in ->{sock}. Add tests to ensure USR2 works regardless of whether workers are enabled or not. --- lib/PublicInbox/Daemon.pm | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/PublicInbox') diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm index 43ef2691..3d582e35 100644 --- a/lib/PublicInbox/Daemon.pm +++ b/lib/PublicInbox/Daemon.pm @@ -403,6 +403,9 @@ sub upgrade { # $_[0] = signal name or number (unused) $ENV{LISTEN_FDS} = scalar @listeners; $ENV{LISTEN_PID} = $$; foreach my $s (@listeners) { + # @listeners are globs with workers, PI::L w/o workers + $s = $s->{sock} if ref($s) eq 'PublicInbox::Listener'; + my $fl = fcntl($s, F_GETFD, 0); fcntl($s, F_SETFD, $fl &= ~FD_CLOEXEC); } -- cgit v1.2.3-24-ge0c7