]> Sergey Matveev's repositories - public-inbox.git/commitdiff
daemon: unconditionally call IO::Handle::blocking(0)
authorEric Wong <e@80x24.org>
Sun, 20 Dec 2020 06:30:14 +0000 (06:30 +0000)
committerEric Wong <e@80x24.org>
Sun, 20 Dec 2020 20:39:13 +0000 (20:39 +0000)
IO::Handle::blocking will always return the initial value from
the F_GETFL op and it won't issue F_SETFL if a socket is already
non-blocking.

lib/PublicInbox/Daemon.pm

index d1a42fc348a4ae4fbd8d4cd32809e7d0a06d1d75..eeac3bd204460d17a4b01450f9f9c1e83e585177 100644 (file)
@@ -367,14 +367,12 @@ sub inherit ($) {
        foreach my $fd (3..$end) {
                my $s = IO::Handle->new_from_fd($fd, 'r');
                if (my $k = sockname($s)) {
-                       if ($s->blocking) {
-                               $s->blocking(0);
-                               warn <<"";
+                       my $prev_was_blocking = $s->blocking(0);
+                       warn <<"" if $prev_was_blocking;
 Inherited socket (fd=$fd) is blocking, making it non-blocking.
 Set 'NonBlocking = true' in the systemd.service unit to avoid stalled
 processes when multiple service instances start.
 
-                       }
                        $listener_names->{$k} = $s;
                        push @rv, $s;
                } else {