about summary refs log tree commit homepage
path: root/cmogstored.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-11-14 20:55:01 +0000
committerEric Wong <normalperson@yhbt.net>2012-11-14 21:00:39 +0000
commit41327689fb727843de258ec99145b78631f821a6 (patch)
tree985c435ce8ab95db52fd04da3fae480187bd0543 /cmogstored.c
parente848b1794240281e93fc2715b0b44238025e3552 (diff)
downloadcmogstored-41327689fb727843de258ec99145b78631f821a6.tar.gz
This allows admins to reuse management scripts originally
written for Perl mogstored with cmogstored.
Diffstat (limited to 'cmogstored.c')
-rw-r--r--cmogstored.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmogstored.c b/cmogstored.c
index 7b7d4fd..6bb3848 100644
--- a/cmogstored.c
+++ b/cmogstored.c
@@ -15,6 +15,7 @@ static sig_atomic_t sigchld_nr;
 static sig_atomic_t do_exit;
 static size_t nthr;
 static bool have_mgmt;
+static pid_t master_pid;
 static unsigned long worker_processes;
 static Hash_table *workers;
 struct worker {
@@ -267,6 +268,8 @@ MOG_NOINLINE static void setup(int argc, char *argv[])
                        "failed to write pidfile(%s): %m. continuing...",
                        mog_cli.pidfile);
 
+        master_pid = getpid();
+
         /* 10 - 100 threads based on number of devices, same as mogstored */
         nthr = mog_mkusage_all() * 10;
         nthr = MAX(10, nthr);
@@ -576,3 +579,15 @@ int main(int argc, char *argv[], char *envp[])
 
         return 0;
 }
+
+/* called by the "shutdown" command via mgmt */
+void cmogstored_quit(void)
+{
+        if (worker_processes > 0) {
+                if (kill(master_pid, SIGQUIT) != 0)
+                        syslog(LOG_ERR,
+                               "SIGQUIT failed on master process (pid=%d): %m",
+                                master_pid);
+        }
+        worker_wakeup_handler(SIGQUIT);
+}