about summary refs log tree commit homepage
path: root/lib/PublicInbox/Qspawn.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-06-24 02:52:26 +0000
committerEric Wong <e@80x24.org>2019-06-24 05:26:26 +0000
commit7c89df780b7b160fe85b8a355455d06ec8499205 (patch)
tree5d741af972a2c4418a10a26b90f069e8fc689e9e /lib/PublicInbox/Qspawn.pm
parentcee1b928497c002ba03c325cbc6de7022673e2cb (diff)
downloadpublic-inbox-7c89df780b7b160fe85b8a355455d06ec8499205.tar.gz
Integer comparisions of "$!" are faster than hash lookups.

See commit 6fa2b29fcd0477d126ebb7db7f97b334f74bbcbc
("ds: cleanup Errno imports and favor constant comparisons")
for benchmarks.
Diffstat (limited to 'lib/PublicInbox/Qspawn.pm')
-rw-r--r--lib/PublicInbox/Qspawn.pm7
1 files changed, 5 insertions, 2 deletions
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);
         };