From 7c89df780b7b160fe85b8a355455d06ec8499205 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 24 Jun 2019 02:52:26 +0000 Subject: http|nntp: favor "$! == EFOO" over $!{EFOO} checks Integer comparisions of "$!" are faster than hash lookups. See commit 6fa2b29fcd0477d126ebb7db7f97b334f74bbcbc ("ds: cleanup Errno imports and favor constant comparisons") for benchmarks. --- lib/PublicInbox/Qspawn.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/Qspawn.pm') diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm index 943ee801..f2630a0f 100644 --- a/lib/PublicInbox/Qspawn.pm +++ b/lib/PublicInbox/Qspawn.pm @@ -29,6 +29,9 @@ use warnings; use PublicInbox::Spawn qw(popen_rd); require Plack::Util; +# n.b.: we get EAGAIN with public-inbox-httpd, and EINTR on other PSGI servers +use Errno qw(EAGAIN EINTR); + my $def_limiter; # declares a command to spawn (but does not spawn it). @@ -131,7 +134,7 @@ sub psgi_qx { } elsif (defined $r) { $r ? $qx->write($buf) : $end->(); } else { - return if $!{EAGAIN} || $!{EINTR}; # loop again + return if $! == EAGAIN || $! == EINTR; # loop again $end->(); } }; @@ -193,7 +196,7 @@ sub psgi_return { my $buf = ''; my $rd_hdr = sub { my $r = sysread($rpipe, $buf, 1024, length($buf)); - return if !defined($r) && ($!{EINTR} || $!{EAGAIN}); + return if !defined($r) && $! == EAGAIN || $! == EINTR; $parse_hdr->($r, \$buf); }; -- cgit v1.2.3-24-ge0c7