]> git.tuebingen.mpg.de Git - dss.git/commitdiff
Restart the rsync process if it returned with exit code 13.
authorAndre Noll <maan@systemlinux.org>
Mon, 7 Jul 2008 14:29:38 +0000 (16:29 +0200)
committerAndre Noll <maan@systemlinux.org>
Mon, 7 Jul 2008 14:29:38 +0000 (16:29 +0200)
Unfortunately this happens frequently for no apparent reason.

dss.c
snap.h

diff --git a/dss.c b/dss.c
index 7a46eed23531dd2f3dfa657bce877414ee5b2a0c..af1326fd5ad4d7262814d85f3dbdb203c9736fb8 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -498,6 +498,13 @@ static int handle_rsync_exit(int status)
                goto out;
        }
        es = WEXITSTATUS(status);
+       if (es == 13) { /* Errors with program diagnostics */
+               DSS_WARNING_LOG("rsync process %d returned %d -- restarting\n",
+                       (int)rsync_pid, es);
+               snapshot_creation_status = SCS_RSYNC_NEEDS_RESTART;
+               ret = 1;
+               goto out;
+       }
        if (es != 0 && es != 23 && es != 24) {
                DSS_ERROR_LOG("rsync process %d returned %d\n", (int)rsync_pid, es);
                ret = -E_BAD_EXIT_CODE;
@@ -726,6 +733,9 @@ static void create_rsync_argv(char ***argv, int64_t *num)
 static void free_rsync_argv(char **argv)
 {
        int i;
+
+       if (!argv)
+               return;
        for (i = 0; argv[i]; i++)
                free(argv[i]);
        free(argv);
@@ -751,11 +761,11 @@ static int select_loop(void)
        int ret;
        /* check every 60 seconds for free disk space */
        struct timeval tv;
+       char **rsync_argv = NULL;
 
        for (;;) {
                fd_set rfds;
                int low_disk_space;
-               char **rsync_argv;
                struct timeval now, *tvp;
 
                if (rm_pid)
@@ -801,10 +811,15 @@ static int select_loop(void)
                        continue;
                case SCS_PRE_HOOK_RUNNING:
                        continue;
+               case SCS_RSYNC_NEEDS_RESTART:
+                       ret = create_snapshot(rsync_argv);
+                       if (ret < 0)
+                               goto out;
+                       continue;
                case SCS_PRE_HOOK_SUCCESS:
+                       free_rsync_argv(rsync_argv);
                        create_rsync_argv(&rsync_argv, &current_snapshot_creation_time);
                        ret = create_snapshot(rsync_argv);
-                       free_rsync_argv(rsync_argv);
                        if (ret < 0)
                                goto out;
                        continue;
diff --git a/snap.h b/snap.h
index 52f060b8a8dd790194925ac481e44af32a808973..063a38e2497f86eba22416679fc4b37137f2d94e 100644 (file)
--- a/snap.h
+++ b/snap.h
@@ -16,6 +16,8 @@ enum {
        SCS_RSYNC_RUNNING,
        /** The rsync process exited successfully. */
        SCS_RSYNC_SUCCESS,
+       /** The rsync process needs to be restarted. */
+       SCS_RSYNC_NEEDS_RESTART,
        /** The post-create hook has been started. */
        SCS_POST_HOOK_RUNNING,
 };