summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ctdb/doc/cluster_mutex_helper.txt3
-rw-r--r--ctdb/server/ctdb_mutex_fcntl_helper.c13
2 files changed, 15 insertions, 1 deletions
diff --git a/ctdb/doc/cluster_mutex_helper.txt b/ctdb/doc/cluster_mutex_helper.txt
index 0fc3a50dc7c..20c8eb2b51d 100644
--- a/ctdb/doc/cluster_mutex_helper.txt
+++ b/ctdb/doc/cluster_mutex_helper.txt
@@ -64,7 +64,8 @@ Valid status codes are:
If a 0 status code is sent then it the helper should periodically
check if the (original) parent processes still exists while awaiting
termination. If the parent process disappears then the helper should
-release the mutex and exit. This avoids stale mutexes.
+release the mutex and exit. This avoids stale mutexes. Note that a
+helper should never wait for parent process ID 1!
If a non-0 status code is sent then the helper can exit immediately.
However, if the helper does not exit then it must terminate if it
diff --git a/ctdb/server/ctdb_mutex_fcntl_helper.c b/ctdb/server/ctdb_mutex_fcntl_helper.c
index 06c2205d496..87358beb234 100644
--- a/ctdb/server/ctdb_mutex_fcntl_helper.c
+++ b/ctdb/server/ctdb_mutex_fcntl_helper.c
@@ -82,6 +82,19 @@ int main(int argc, char *argv[])
}
ppid = getppid();
+
+ if (ppid == 1) {
+ /* The original parent is gone and the process has
+ * been reparented to init. This can happen if the
+ * helper is started just as the parent is killed
+ * during shutdown. The error message doesn't need to
+ * be stellar, since there won't be anything around to
+ * capture and log it...
+ */
+ fprintf(stderr, "%s: PPID == 1\n", progname);
+ exit(1);
+ }
+
file = argv[1];
result = fcntl_lock(file, &fd);