Package: debmirror
Version: 1:2.4.4
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu lucid ubuntu-patch

Hello!

This is expecting to by applied after the default-settings.patch and
command-exit-checking.patch patches from bug 455082, and it adds a retry
cycle for rsync connection failures.

Thanks,

-Kees

-- 
Kees Cook                                            @debian.org
Description: attempt to re-connect to rsync servers that time-out.
Author: Kees Cook <k...@ubuntu.com>

Index: debmirror-2.4.4/debmirror
===================================================================
--- debmirror-2.4.4.orig/debmirror	2010-04-05 12:07:15.000000000 -0700
+++ debmirror-2.4.4/debmirror	2010-04-05 12:12:12.413282860 -0700
@@ -1297,8 +1297,21 @@
 	      print $fh "$_\n";
 	    }
 	  }
-	  system ("rsync --no-motd --timeout=$timeout $opt $rsyncremote --include-from=$rsynctempfile --exclude='*' $mirrordir");
-	  die "rsync failed!" if ($? != 0);
+	  my $limit = 10;
+	  while (1) {
+	    system ("rsync --no-motd --timeout=$timeout $opt $rsyncremote --include-from=$rsynctempfile --exclude='*' $mirrordir");
+	    my $rc = $?;
+	    last if ($rc == 0);
+	    # Retry on connection failures
+	    if ($rc == 5<<8) {
+	      die "rsync failed too many times!" if (--$limit == 0);
+	      say("Pausing before retry...");
+	      sleep(30);
+	    }
+	    else {
+	      die "rsync failed!";
+	    }
+	  }
 	  close $fh;
 	  unlink $rsynctempfile;
 	  foreach my $dest (@result) {

Reply via email to