X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;ds=sidebyside;f=dss.c;h=86e83827f50991fc9460eb44c71b45211b7fc1a8;hb=df465017098a79eaa7b1c1c2f958f262b4dc521e;hp=b27bdf6604d14f44dfa34d402e1c22f6e37055ae;hpb=a6727ed6659f287eb2a4f68ac5fbf3178f40498f;p=dss.git diff --git a/dss.c b/dss.c index b27bdf6..86e8382 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; @@ -826,16 +841,13 @@ out: static void exit_hook(int exit_code) { int fds[3] = {0, 0, 0}; - char *cmd; + char *argv[] = {conf.exit_hook_arg, dss_strerror(-exit_code), NULL}; pid_t pid; if (!conf.exit_hook_given) return; - cmd = make_message("%s %s", conf.exit_hook_arg, - dss_strerror(-exit_code)); - DSS_NOTICE_LOG("executing %s\n", cmd); - dss_exec_cmdline_pid(&pid, cmd, fds); - free(cmd); + DSS_NOTICE_LOG("executing %s %s\n", argv[0], argv[1]); + dss_exec(&pid, conf.exit_hook_arg, argv, fds); } static int com_run(void) @@ -952,8 +964,12 @@ static int com_ls(void) struct snapshot *s; dss_get_snapshot_list(&sl); - FOR_EACH_SNAPSHOT(s, i, &sl) - dss_msg("%u\t%s\n", s->interval, s->name); + FOR_EACH_SNAPSHOT(s, i, &sl) { + int64_t d = 0; + if (s->flags & SS_COMPLETE) + d = (s->completion_time - s->creation_time) / 60; + dss_msg("%u\t%s\t%3" PRId64 ":%02" PRId64 "\n", s->interval, s->name, d/60, d%60); + }; free_snapshot_list(&sl); return 1; }