From 64964f0639b13787a06bea76f922cba18731807c Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 28 Aug 2009 15:23:57 +0200 Subject: [PATCH] Properly invalidate create_pid also for the post-create hook. If the process associated with the create_pid dies, handle_sigchld() investigates snapshot_creation_status to tell whether the pre-create hook, the rsync process or the post-create hook has died. In the first two cases, handle_pre_create_hook_exit() and handle_rsync_exit() are called, respectively. Both functions correctly invalidate create_pid (by resetting it to zero). However, the post-create hook handling code misses to reset create_pid. This causes dss to send SIGTERM to this pid on exit, which might be fatal as the pid might have been reassigned to some unrelated process in the meanwhile. Fix this bug by moving the invalidation of create_pid to the end of the "if (pid == create_pid)" clause, which even saves a line of code. Many thanks to Sebastian Stark who pointed out that bug. --- dss.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dss.c b/dss.c index c5f636c..93ab802 100644 --- a/dss.c +++ b/dss.c @@ -734,7 +734,6 @@ static int handle_rsync_exit(int status) free(name_of_reference_snapshot); name_of_reference_snapshot = NULL; out: - create_pid = 0; create_process_stopped = 0; return ret; } @@ -766,7 +765,6 @@ static int handle_pre_create_hook_exit(int status) snapshot_creation_status = HS_PRE_SUCCESS; ret = 1; out: - create_pid = 0; return ret; } @@ -792,6 +790,7 @@ static int handle_sigchld(void) snapshot_creation_status); return -E_BUG; } + create_pid = 0; } if (pid == remove_pid) { ret = handle_remove_exit(status); -- 2.39.5