From 64161529ebe151e36c7fc86b419543b4ac02a681 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Wed, 13 Apr 2011 01:46:01 +0000 Subject: syncdaemon: fix pidfile deletion on failed pidfile acquisition (not triggered in glusterd instrumentation of gsyncd as glusterd does pidfile probing by itself) Signed-off-by: Csaba Henk Signed-off-by: Anand Avati BUG: 1570 (geosync related changes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1570 --- xlators/features/marker/utils/syncdaemon/gsyncd.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'xlators/features/marker/utils/syncdaemon') diff --git a/xlators/features/marker/utils/syncdaemon/gsyncd.py b/xlators/features/marker/utils/syncdaemon/gsyncd.py index d759f6b8dba..2ce11a8aa39 100644 --- a/xlators/features/marker/utils/syncdaemon/gsyncd.py +++ b/xlators/features/marker/utils/syncdaemon/gsyncd.py @@ -75,6 +75,8 @@ def grabfile(fname, content=None): gconf.permanent_handles.append(f) return f +pid_file_owned = False + def grabpidfile(fname=None, setpid=True): if not fname: fname = gconf.pid_file @@ -84,10 +86,13 @@ def grabpidfile(fname=None, setpid=True): return grabfile(fname, content=content) def startup(**kw): + global pid_file_owned + if getattr(gconf, 'pid_file', None) and kw.get('go_daemon') != 'postconn': if not grabpidfile(): sys.stderr.write("pidfile is taken, exiting.\n") sys.exit(2) + pid_file_owned = True if kw.get('go_daemon') == 'should': x, y = os.pipe() @@ -125,7 +130,7 @@ def startup(**kw): def finalize(*a): if getattr(gconf, 'pid_file', None): - rm_pidf = True + rm_pidf = pid_file_owned if gconf.cpid: # exit path from parent branch of daemonization rm_pidf = False -- cgit