Skip to content

Commit

Permalink
Fix retries in git-cvsimport
Browse files Browse the repository at this point in the history
Fixed a couple of bugs in recovering from broken connections:

The _line() method now returns undef correctly when the connection
is broken instead of falling off the function and returning garbage.

Retries are now reported to stderr and the eventual partially
downloaded file is discarded instead of being appended to.

The "Server gone away" test has been removed, because it was
reachable only if the garbage return bug bit.

Signed-off-by: Martin Mares <mj@ucw.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Martin Mares authored and Junio C Hamano committed Feb 19, 2006
1 parent 3ff903b commit 39ba7d5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions git-cvsimport.perl
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ sub _line {
}
}
}
return undef;
}
sub file {
my($self,$fn,$rev) = @_;
Expand All @@ -372,19 +373,15 @@ sub file {
$self->_file($fn,$rev) and $res = $self->_line($fh);

if (!defined $res) {
# retry
print STDERR "Server has gone away while fetching $fn $rev, retrying...\n";
truncate $fh, 0;
$self->conn();
$self->_file($fn,$rev)
or die "No file command send\n";
$self->_file($fn,$rev) or die "No file command send";
$res = $self->_line($fh);
die "No input: $fn $rev\n" unless defined $res;
die "Retry failed" unless defined $res;
}
close ($fh);

if ($res eq '') {
die "Looks like the server has gone away while fetching $fn $rev -- exiting!";
}

return ($name, $res);
}

Expand Down

0 comments on commit 39ba7d5

Please sign in to comment.