From: Andre Noll Date: Mon, 30 Mar 2009 10:49:03 +0000 (+0200) Subject: Fix the pre-create hook. X-Git-Tag: v0.1.3~15^2~2 X-Git-Url: http://git.tuebingen.mpg.de/?p=dss.git;a=commitdiff_plain;h=381c57770c21974e190e52980a4936a060fc8696 Fix the pre-create hook. Returning non-zero from the pre-create hook caused dss to exit with "unexpected exit code" rather than waiting until the hook returns zero. Fix this bug and also reduce the verbostity of the log messages caused by executing the pre-create hook: It should be enough to tell the user only once per hour that no more snapshots are going to be created. --- diff --git a/dss.c b/dss.c index fd876e5..2a18857 100644 --- a/dss.c +++ b/dss.c @@ -367,7 +367,7 @@ static int pre_create_hook(void) snapshot_creation_status = SCS_PRE_HOOK_SUCCESS; return 0; } - DSS_NOTICE_LOG("executing %s\n", conf.pre_create_hook_arg); + DSS_DEBUG_LOG("executing %s\n", conf.pre_create_hook_arg); ret = dss_exec_cmdline_pid(&create_pid, conf.pre_create_hook_arg, fds); if (ret < 0) @@ -532,6 +532,7 @@ out: static int handle_pre_create_hook_exit(int status) { int es, ret; + static int warn_count; if (!WIFEXITED(status)) { snapshot_creation_status = SCS_READY; @@ -541,11 +542,18 @@ static int handle_pre_create_hook_exit(int status) } es = WEXITSTATUS(status); if (es) { + if (!warn_count--) { + DSS_NOTICE_LOG("pre_create_hook %s returned %d\n", + conf.pre_create_hook_arg, es); + DSS_NOTICE_LOG("deferring snapshot creation...\n"); + warn_count = 60; /* warn only once per hour */ + } snapshot_creation_status = SCS_READY; compute_next_snapshot_time(); - ret = -E_BAD_EXIT_CODE; + ret = 0; goto out; } + warn_count = 0; snapshot_creation_status = SCS_PRE_HOOK_SUCCESS; ret = 1; out: