diff options
author | Hannes Reinecke <hare@suse.de> | 2009-04-28 11:11:23 +0200 |
---|---|---|
committer | Hannes Reinecke <hare@suse.de> | 2011-05-18 11:02:17 +0200 |
commit | 3b4bc7d987e2ba4ab725a0bd24276306a5143ba3 (patch) | |
tree | 10ce1e7aefabf88ad06ede15a2ebb039dcb5482d | |
parent | 13520b8a0c99d1a82e17a8b9d3d37123246140ee (diff) | |
download | multipath-tools-3b4bc7d987e2ba4ab725a0bd24276306a5143ba3.tar.gz |
Add 'shutdown' cli command
Rather than sending a signal to the process (which might get caught
by any thread, possibly blocking it) we can as well implement a
'shutdown' cli command, making sure the daemon will be terminated.
Signed-off-by: Hannes Reinecke <hare@suse.de>
-rw-r--r-- | multipathd/cli.c | 2 | ||||
-rw-r--r-- | multipathd/cli.h | 6 | ||||
-rw-r--r-- | multipathd/cli_handlers.c | 8 | ||||
-rw-r--r-- | multipathd/cli_handlers.h | 1 | ||||
-rw-r--r-- | multipathd/main.c | 3 | ||||
-rw-r--r-- | multipathd/main.h | 1 |
6 files changed, 18 insertions, 3 deletions
diff --git a/multipathd/cli.c b/multipathd/cli.c index 3316004..782d886 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -180,6 +180,7 @@ load_keys (void) r += add_key(keys, "wildcards", WILDCARDS, 0); r += add_key(keys, "quit", QUIT, 0); r += add_key(keys, "exit", QUIT, 0); + r += add_key(keys, "shutdown", SHUTDOWN, 0); if (r) { free_keys(keys); @@ -445,6 +446,7 @@ cli_init (void) { add_handler(REINSTATE+PATH, NULL); add_handler(FAIL+PATH, NULL); add_handler(QUIT, NULL); + add_handler(SHUTDOWN, NULL); return 0; } diff --git a/multipathd/cli.h b/multipathd/cli.h index 41f4952..8971ff6 100644 --- a/multipathd/cli.h +++ b/multipathd/cli.h @@ -25,6 +25,7 @@ enum { __FMT, __WILDCARDS, __QUIT, + __SHUTDOWN, }; #define LIST (1 << __LIST) @@ -49,11 +50,12 @@ enum { #define TOPOLOGY (1 << __TOPOLOGY) #define CONFIG (1 << __CONFIG) #define BLACKLIST (1 << __BLACKLIST) -#define DEVICES (1 << __DEVICES) -#define FMT (1 << __FMT) +#define DEVICES (1 << __DEVICES) +#define FMT (1 << __FMT) #define COUNT (1 << __COUNT) #define WILDCARDS (1 << __WILDCARDS) #define QUIT (1 << __QUIT) +#define SHUTDOWN (1 << __SHUTDOWN) #define INITIAL_REPLY_LEN 1000 diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index d56a990..3c4d838 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -812,3 +812,11 @@ cli_quit (void * v, char ** reply, int * len, void * data) { return 0; } + +int +cli_shutdown (void * v, char ** reply, int * len, void * data) +{ + condlog(3, "shutdown (operator)"); + + return exit_daemon(0); +} diff --git a/multipathd/cli_handlers.h b/multipathd/cli_handlers.h index b3ad377..8fe9e06 100644 --- a/multipathd/cli_handlers.h +++ b/multipathd/cli_handlers.h @@ -27,3 +27,4 @@ int cli_resume(void * v, char ** reply, int * len, void * data); int cli_reinstate(void * v, char ** reply, int * len, void * data); int cli_fail(void * v, char ** reply, int * len, void * data); int cli_quit(void * v, char ** reply, int * len, void * data); +int cli_shutdown(void * v, char ** reply, int * len, void * data); diff --git a/multipathd/main.c b/multipathd/main.c index ebb8b1b..d11ecdc 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -806,6 +806,7 @@ uxlsnrloop (void * ap) set_handler_callback(DISABLEQ+MAPS, cli_disable_all_queueing); set_handler_callback(RESTOREQ+MAPS, cli_restore_all_queueing); set_handler_callback(QUIT, cli_quit); + set_handler_callback(SHUTDOWN, cli_shutdown); umask(077); uxsock_listen(&uxsock_trigger, ap); @@ -813,7 +814,7 @@ uxlsnrloop (void * ap) return NULL; } -static int +int exit_daemon (int status) { if (status != 0) diff --git a/multipathd/main.h b/multipathd/main.h index 3990967..f8487c0 100644 --- a/multipathd/main.h +++ b/multipathd/main.h @@ -3,6 +3,7 @@ #define MAPGCINT 5 +int exit_daemon(int); int reconfigure (struct vectors *); int ev_add_path (char *, struct vectors *); int ev_remove_path (char *, struct vectors *); |