* [PATCH] popen_rd
@ 2016-05-22 6:03 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-05-22 6:03 UTC (permalink / raw)
To: spew
---
lib/PublicInbox/GitHTTPBackend.pm | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/lib/PublicInbox/GitHTTPBackend.pm b/lib/PublicInbox/GitHTTPBackend.pm
index b58cc30..fdf0cbb 100644
--- a/lib/PublicInbox/GitHTTPBackend.pm
+++ b/lib/PublicInbox/GitHTTPBackend.pm
@@ -8,7 +8,7 @@ use strict;
use warnings;
use Fcntl qw(:seek);
use IO::File;
-use PublicInbox::Spawn qw(spawn);
+use PublicInbox::Spawn qw(popen_rd);
use HTTP::Date qw(time2str);
# TODO: make configurable, but keep in mind it's better to have
@@ -214,11 +214,6 @@ sub serve_smart {
} else {
$in = input_to_file($env) or return r(500);
}
- my ($rpipe, $wpipe);
- unless (pipe($rpipe, $wpipe)) {
- err($env, "error creating pipe: $! - going static");
- return;
- }
my %env = %ENV;
# GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL
# may be set in the server-process and are passed as-is
@@ -234,13 +229,9 @@ sub serve_smart {
my $git_dir = $git->{git_dir};
$env{GIT_HTTP_EXPORT_ALL} = '1';
$env{PATH_TRANSLATED} = "$git_dir/$path";
- my %rdr = ( 0 => fileno($in), 1 => fileno($wpipe) );
- my $pid = spawn([qw(git http-backend)], \%env, \%rdr);
- unless (defined $pid) {
- err($env, "error spawning: $! - going static");
- return;
- }
- $wpipe = $in = undef;
+ my %rdr = ( 0 => fileno($in) );
+ my $rpipe = popen_rd([qw(git http-backend)], \%env, \%rdr);
+ $in = undef;
$buf = '';
my ($vin, $fh, $res);
$nr_running++;
@@ -264,12 +255,9 @@ sub serve_smart {
# PublicInbox::HTTPD::Async::close:
$rpipe->close;
$rpipe = undef;
- $nr_running--;
- }
- if (defined $pid) {
- my $e = $pid == waitpid($pid, 0) ?
- $? : "PID:$pid still running?";
+ my $e = $?;
err($env, "git http-backend ($git_dir): $e") if $e;
+ $nr_running--;
}
return unless $res;
my $dumb = serve_dumb($cgi, $git, $path);
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-05-22 6:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-22 6:03 [PATCH] popen_rd Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).