aboutsummaryrefslogtreecommitdiffstats
path: root/pbx/pbx_dundi.c
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-27 00:58:35 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-27 00:58:35 +0000
commitcd0cc3ada5b82cdae4d4fd952a5e53dee00e9807 (patch)
tree1e5cfe806a327af1776023def163bc1063b5e64a /pbx/pbx_dundi.c
parent974ad7962ed2a40ae77129cc30a8f62874423d53 (diff)
Make unloading of pbx_dundi actually work.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@72006 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx/pbx_dundi.c')
-rw-r--r--pbx/pbx_dundi.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 007c65d13..02e900dca 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -51,6 +51,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <ifaddrs.h>
#endif
#include <zlib.h>
+#include <sys/signal.h>
+#include <pthread.h>
#include "asterisk/file.h"
#include "asterisk/logger.h"
@@ -132,6 +134,7 @@ static char cursecret[80];
static char ipaddr[80];
static time_t rotatetime;
static dundi_eid empty_eid = { { 0, 0, 0, 0, 0, 0 } };
+static int dundi_shutdown = 0;
struct permission {
AST_LIST_ENTRY(permission) list;
@@ -2077,7 +2080,8 @@ static void *network_thread(void *ignore)
int res;
/* Establish I/O callback for socket read */
ast_io_add(io, netsocket, socket_read, AST_IO_IN, NULL);
- for(;;) {
+
+ while (!dundi_shutdown) {
res = ast_sched_wait(sched);
if ((res > 1000) || (res < 0))
res = 1000;
@@ -2100,7 +2104,7 @@ static void *process_precache(void *ign)
char number[256];
int run;
- for (;;) {
+ while (!dundi_shutdown) {
time(&now);
run = 0;
AST_LIST_LOCK(&pcq);
@@ -4461,9 +4465,18 @@ static int unload_module(void)
{
ast_module_user_hangup_all();
+ /* Stop all currently running threads */
+ dundi_shutdown = 1;
+ pthread_kill(netthreadid, SIGURG);
+ pthread_join(netthreadid, NULL);
+ pthread_kill(precachethreadid, SIGURG);
+ pthread_join(precachethreadid, NULL);
+
ast_cli_unregister_multiple(cli_dundi, sizeof(cli_dundi) / sizeof(struct ast_cli_entry));
ast_unregister_switch(&dundi_switch);
ast_custom_function_unregister(&dundi_function);
+ close(netsocket);
+ io_context_destroy(io);
sched_context_destroy(sched);
return 0;