summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorzuul <zuul@gerrit.asterisk.org>2016-09-20 14:39:04 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2016-09-20 14:39:04 -0500
commit381cafe335e900d0cfd306214cc0312ed8aa86af (patch)
treef2c9c4fc2e5897418802f327bbd27e0ac50db052 /main
parent2c8b8a9ecb88cad35165c671702df99b79239999 (diff)
parent29e096cd13f2a927006ba491dfdae1d900b11b10 (diff)
Merge "sd_notify (systemd status notifications) support" into 14
Diffstat (limited to 'main')
-rw-r--r--main/Makefile1
-rw-r--r--main/asterisk.c4
-rw-r--r--main/io.c10
-rw-r--r--main/loader.c9
4 files changed, 20 insertions, 4 deletions
diff --git a/main/Makefile b/main/Makefile
index a6c3ab1b8..d41302a7f 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -45,6 +45,7 @@ AST_LIBS+=$(UUID_LIB)
AST_LIBS+=$(CRYPT_LIB)
AST_LIBS+=$(AST_CLANG_BLOCKS_LIBS)
AST_LIBS+=$(RT_LIB)
+AST_LIBS+=$(SYSTEMD_LIB)
ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc linux-musl kfreebsd-gnu),)
ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
diff --git a/main/asterisk.c b/main/asterisk.c
index 7b1338c3d..c9e3b59a5 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -2039,6 +2039,9 @@ static void really_quit(int num, shutdown_nice_t niceness, int restart)
ast_module_shutdown();
}
+ if (!restart) {
+ ast_sd_notify("STOPPING=1");
+ }
if (ast_opt_console || (ast_opt_remote && !ast_opt_exec)) {
ast_el_write_default_histfile();
if (consolethread == AST_PTHREADT_NULL || consolethread == pthread_self()) {
@@ -4566,6 +4569,7 @@ static void asterisk_daemon(int isroot, const char *runuser, const char *rungrou
ast_register_cleanup(main_atexit);
run_startup_commands();
+ ast_sd_notify("READY=1");
ast_verb(0, COLORIZE_FMT "\n", COLORIZE(COLOR_BRGREEN, 0, "Asterisk Ready."));
diff --git a/main/io.c b/main/io.c
index ff5ca57f7..3441fbae9 100644
--- a/main/io.c
+++ b/main/io.c
@@ -36,6 +36,9 @@ ASTERISK_REGISTER_FILE()
#include "asterisk/io.h"
#include "asterisk/utils.h"
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-daemon.h>
+#endif
#ifdef DEBUG_IO
#define DEBUG DEBUG_M
@@ -384,3 +387,10 @@ int ast_get_termcols(int fd)
return cols;
}
+int ast_sd_notify(const char *state) {
+#ifdef HAVE_SYSTEMD
+ return sd_notify(0, state);
+#else
+ return 0;
+#endif
+}
diff --git a/main/loader.c b/main/loader.c
index f95922173..36a3d5f61 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -891,6 +891,7 @@ enum ast_module_reload_result ast_module_reload(const char *name)
res = AST_MODULE_RELOAD_IN_PROGRESS;
goto module_reload_exit;
}
+ ast_sd_notify("RELOAD=1");
ast_lastreloadtime = ast_tvnow();
if (ast_opt_lock_confdir) {
@@ -904,9 +905,8 @@ enum ast_module_reload_result ast_module_reload(const char *name)
}
if (res != AST_LOCK_SUCCESS) {
ast_log(AST_LOG_WARNING, "Cannot grab lock on %s\n", ast_config_AST_CONFIG_DIR);
- ast_mutex_unlock(&reloadlock);
res = AST_MODULE_RELOAD_ERROR;
- goto module_reload_exit;
+ goto module_reload_done;
}
}
@@ -923,8 +923,7 @@ enum ast_module_reload_result ast_module_reload(const char *name)
if (ast_opt_lock_confdir) {
ast_unlock_path(ast_config_AST_CONFIG_DIR);
}
- ast_mutex_unlock(&reloadlock);
- goto module_reload_exit;
+ goto module_reload_done;
}
AST_DLLIST_LOCK(&module_list);
@@ -966,7 +965,9 @@ enum ast_module_reload_result ast_module_reload(const char *name)
if (ast_opt_lock_confdir) {
ast_unlock_path(ast_config_AST_CONFIG_DIR);
}
+module_reload_done:
ast_mutex_unlock(&reloadlock);
+ ast_sd_notify("READY=1");
module_reload_exit:
publish_reload_message(name, res);