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-26 06:36:27 +0000
committerEric Wong <e@80x24.org>2019-06-26 06:36:27 +0000
commit84d8920b92686e975929aebe845b6d4ea0a9ef0d (patch)
tree91a1123aaa44ad8fbb63c9dbf912d6dca95b0818 /lib/PublicInbox/Qspawn.pm
parentc19a4e88f49ba3496751c4b87ebcfa0f6b47f0ce (diff)
parentc30b4427b340aeb242273a7b890fbd7e50132f51 (diff)
downloadpublic-inbox-84d8920b92686e975929aebe845b6d4ea0a9ef0d.tar.gz
* origin/nntp-tls: (59 commits)
  ds: ->write must not clobber empty wbuf array
  Makefile: skip DSKQXS in global syntax check
  ds: reduce overhead of tempfile creation
  Revert "ci: require IO::KQueue on FreeBSD, for now"
  ds: reimplement IO::Poll support to look like epoll
  ds: split out IO::KQueue-specific code
  daemon: use FreeBSD accept filters on non-NNTP
  daemon: set TCP_DEFER_ACCEPT on everything but NNTP
  nntp: send greeting immediately for plain sockets
  ci: require IO::KQueue on FreeBSD, for now
  nntp: lazily allocate and stash rbuf
  ds: flush_write runs ->write callbacks even if closed
  nntp: simplify long response logic and fix nesting
  ds: always use EV_ADD with EV_SET
  nntp: reduce allocations for greeting
  ds: allow ->write callbacks to syswrite directly
  daemon: use SSL_MODE_RELEASE_BUFFERS
  t/nntpd-tls: slow client connection test
  nntp: call SSL_shutdown in normal cases
  ds|nntp: use CORE::close on socket
  ...
Diffstat (limited to 'lib/PublicInbox/Qspawn.pm')
-rw-r--r--lib/PublicInbox/Qspawn.pm11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm
index 9aede103..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).
@@ -122,7 +125,7 @@ sub psgi_qx {
                 eval { $qx_cb->($qx) };
                 $qx = undef;
         };
-        my $rpipe;
+        my $rpipe; # comes from popen_rd
         my $async = $env->{'pi-httpd.async'};
         my $cb = sub {
                 my $r = sysread($rpipe, my $buf, 8192);
@@ -131,13 +134,13 @@ 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->();
                 }
         };
         $limiter ||= $def_limiter ||= PublicInbox::Qspawn::Limiter->new(32);
         $self->start($limiter, sub { # may run later, much later...
-                ($rpipe) = @_;
+                ($rpipe) = @_; # popen_rd result
                 if ($async) {
                 # PublicInbox::HTTPD::Async->new($rpipe, $cb, $end)
                         $async = $async->($rpipe, $cb, $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);
         };