diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-01-30 17:23:56 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-01-30 17:23:56 +0000 |
commit | fb998cea26d3302b134dd109b5e324f22b19b66a (patch) | |
tree | 23919f48d0f4c31393844a9f1da3031c445e022a /main/asterisk.c | |
parent | 732bc823e11d3291265249698697bab21eba4bd5 (diff) |
Merged revisions 52904 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r52904 | russell | 2007-01-30 11:19:39 -0600 (Tue, 30 Jan 2007) | 17 lines
Merged revisions 52903 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r52903 | russell | 2007-01-30 11:12:04 -0600 (Tue, 30 Jan 2007) | 9 lines
The SIGHUP handler was implemented to allow admins to send SIGHUP to a running
Asterisk process to reload the configuration. However, doing the actual reload
in the signal handler itself is a very bad thing to do, because the reload
process includes calling non-reentrant functions such as malloc/calloc/etc.
If Asterisk is running in the background, then the reload will happen
immediately. However, if running in console mode, the reload doesn't work
until something is typed at the console. That sort of defeats the purpose,
but I don't see an easy way to get around it at this point.
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@52905 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/asterisk.c')
-rw-r--r-- | main/asterisk.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index 52847a3f9..315e7ae67 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -234,6 +234,8 @@ static pthread_t consolethread = AST_PTHREADT_NULL; static char randompool[256]; +static unsigned int need_reload; + #if !defined(LOW_MEMORY) struct file_version { AST_LIST_ENTRY(file_version) list; @@ -993,8 +995,7 @@ static void hup_handler(int num) printf("Received HUP signal -- Reloading configs\n"); if (restartnow) execvp(_argv[0], _argv); - /* XXX This could deadlock XXX */ - ast_module_reload(NULL); + need_reload = 1; signal(num, hup_handler); } @@ -2132,6 +2133,11 @@ static void ast_remotecontrol(char * data) } } } + + if (need_reload) { + need_reload = 0; + ast_module_reload(NULL); + } } printf("\nDisconnected from Asterisk server\n"); } @@ -2807,14 +2813,21 @@ int main(int argc, char *argv[]) ast_log(LOG_WARNING, "Failed to open /dev/null to recover from dead console. Bad things will happen!\n"); break; } + if (need_reload) { + need_reload = 0; + ast_module_reload(NULL); + } } - } /* Do nothing */ for (;;) { /* apparently needed for Mac OS X */ struct pollfd p = { -1 /* no descriptor */, 0, 0 }; - poll(&p, 0, -1); + /* SIGHUP will cause this to break out of poll() */ + if (need_reload) { + need_reload = 0; + ast_module_reload(NULL); + } } return 0; |