chiark / gitweb /
In rpush, on protocol error talking to build host, check if the subprocess died and...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 Aug 2014 19:42:03 +0000 (20:42 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 Aug 2014 19:42:03 +0000 (20:42 +0100)
debian/changelog
dgit

index f70f2ff689b26fb43feb8304b91d567fa6783a07..fc4bd89bf12dd8721160273063db6acc52945ad7 100644 (file)
@@ -38,6 +38,8 @@ dgit (0.22~experimental1) experimental; urgency=low
     using libdpkg-perl 1.17.x).  Closes:#731635.
   * Improve error message for .dsc parsing failures more generally.
   * Better reporting of child exit statuses (esp. deaths due to signals).
+  * In rpush, on protocol error talking to build host, check if the
+    subprocess died and report differently if so.  Closes:#736528.
 
   Major new feature, currently stalled awaiting server infrastructure:
   * dgit-repos-server: New program for receiving signed-tag-based
diff --git a/dgit b/dgit
index e3fc0eefd33bb6bf0372044f070cc7db03e0ad15..59fabafb5672de394b66ca3d333ae53214a8466c 100755 (executable)
--- 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";