[sheepdog] [PATCH v5] sheep: implement a correct mutex of a base directory
MORITA Kazutaka
morita.kazutaka at gmail.com
Tue Apr 30 08:23:02 CEST 2013
At Tue, 30 Apr 2013 09:14:19 +0900,
Hitoshi Mitake wrote:
>
> Current lockf() usage in lock_base_dir() is invalid bacause sheep
> calls daemon(3) after the lockf(). daemon(3) forks internally and a
> parent process exits immediately. In a case of sheep, daemon() must be
> called after locking base dir so the lock owner, parent process, exits
> and the lock will be released even though the child process is
> running. This is the reason current lock_base_dir() doesn't work
> well. And it causes writing logs to sheep.log from multiple
> sheeps. This phenomenon is very confusing and should be avoided.
>
> This patch implement custom function for daemonizing,
> lock_and_daemon(). And mutex of base directory is done in
> it. lock_and_daemon() does mutex between fork() and closing fd 0, 1,
> and 2, so it can report the failure of mutexing base directory to
> stderr.
>
> Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> ---
> v5: update the commit log
>
> v4: also lock file when sheep runs in foreground
>
> v3: implement custom function for daemonizing and do mutex in it
>
> v2: call exit_handler() from crash_handler() too
>
> sheep/sheep.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++-
> sheep/sheep_priv.h | 1 +
> sheep/store.c | 4 ++--
> 3 files changed, 63 insertions(+), 3 deletions(-)
Applied, thanks!
Kazutaka
More information about the sheepdog
mailing list