summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2014-08-10 20:42:03 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2014-08-10 20:42:03 +0100
commitf0e2a4873a21f9b0399686aad295938891dc5417 (patch)
tree885aba37f8f28aa0aec7d60d8672f2e054fffc46 /dgit
parent5e359c5927e8df1a0ce1652a4b83436e9d5d3410 (diff)
In rpush, on protocol error talking to build host, check if the subprocess died and report differently if so. Closes:#736528.
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit30
1 files changed, 26 insertions, 4 deletions
diff --git a/dgit b/dgit
index e3fc0ee..59fabaf 100755
--- a/dgit
+++ b/dgit
@@ -212,17 +212,39 @@ sub changedir ($) {
#
# > complete
+our $i_child_pid;
+
+sub i_child_report () {
+ # Sees if our child has died, and reap it if so. Returns a string
+ # describing how it died if it failed, or undef otherwise.
+ return undef unless $i_child_pid;
+ my $got = waitpid $i_child_pid, WNOHANG;
+ return undef if $got <= 0;
+ die unless $got == $i_child_pid;
+ $i_child_pid = undef;
+ return undef unless $?;
+ return "build host child ".waitstatusmsg();
+}
+
sub badproto ($$) {
my ($fh, $m) = @_;
fail "connection lost: $!" if $fh->error;
fail "protocol violation; $m not expected";
}
+sub badproto_badread ($$) {
+ my ($fh, $wh) = @_;
+ fail "connection lost: $!" if $!;
+ my $report = i_child_report();
+ fail $report if defined $report;
+ badproto $fh, "eof (reading $wh)";
+}
+
sub protocol_expect (&$) {
my ($match, $fh) = @_;
local $_;
$_ = <$fh>;
- defined && chomp or badproto $fh, "eof";
+ defined && chomp or badproto_badread $fh, "protocol message";
if (wantarray) {
my @r = &$match;
return @r if @r;
@@ -254,7 +276,7 @@ sub protocol_read_bytes ($$) {
$nbytes =~ m/^[1-9]\d{0,5}$/ or badproto \*RO, "bad byte count";
my $d;
my $got = read $fh, $d, $nbytes;
- $got==$nbytes or badproto $fh, "eof during data block";
+ $got==$nbytes or badproto_badread $fh, "data block";
return $d;
}
@@ -1797,10 +1819,10 @@ sub i_resp_progress ($) {
sub i_resp_complete {
my $pid = $i_child_pid;
$i_child_pid = undef; # prevents killing some other process with same pid
- printdebug "waiting for remote child $pid...\n";
+ printdebug "waiting for build host child $pid...\n";
my $got = waitpid $pid, 0;
die $! unless $got == $pid;
- die "remote child failed $?" if $?;
+ die "build host child failed $?" if $?;
i_cleanup();
printdebug "all done\n";