@matheusbsbs / matheus-bagliano / commits / 39ba7d5464
Fork 0

Fix retries in git-cvsimport

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>

Martin Mares committed Feb 18, 2006 at 21:44 UTC 39ba7d54649b35c943b026b54bff40cfa0153f3e
1 file changed +5 -8
git-cvsimport.perl
+5 -8
@@ -361,6 +361,7 @@ sub _line {
361 }
362 }
363 }
364 + return undef;
365 }
366 sub file {
367 my($self,$fn,$rev) = @_;
@@ -372,19 +373,15 @@ sub file {
373 $self->_file($fn,$rev) and $res = $self->_line($fh);
374
375 if (!defined $res) {
375 - # retry
376 + print STDERR "Server has gone away while fetching $fn $rev, retrying...\n";
377 + truncate $fh, 0;
378 $self->conn();
377 - $self->_file($fn,$rev)
378 - or die "No file command send\n";
379 + $self->_file($fn,$rev) or die "No file command send";
380 $res = $self->_line($fh);
380 - die "No input: $fn $rev\n" unless defined $res;
381 + die "Retry failed" unless defined $res;
382 }
383 close ($fh);
384
384 - if ($res eq '') {
385 - die "Looks like the server has gone away while fetching $fn $rev -- exiting!";
386 - }
387 -
385 return ($name, $res);
386 }
387