From b8c18ccfb0dbe89c9a35d4989cd506b8461ea850 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 7 Jul 2008 16:29:38 +0200 Subject: [PATCH] Restart the rsync process if it returned with exit code 13. Unfortunately this happens frequently for no apparent reason. --- dss.c | 19 +++++++++++++++++-- snap.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/dss.c b/dss.c index 7a46eed..af1326f 100644 --- 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, ¤t_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 52f060b..063a38e 100644 --- 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, }; -- 2.39.5