[asterisk-commits] file: branch 1.4 r72006 - /branches/1.4/pbx/pbx_dundi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 26 19:58:35 CDT 2007


Author: file
Date: Tue Jun 26 19:58:35 2007
New Revision: 72006

URL: http://svn.digium.com/view/asterisk?view=rev&rev=72006
Log:
Make unloading of pbx_dundi actually work.

Modified:
    branches/1.4/pbx/pbx_dundi.c

Modified: branches/1.4/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/pbx/pbx_dundi.c?view=diff&rev=72006&r1=72005&r2=72006
==============================================================================
--- branches/1.4/pbx/pbx_dundi.c (original)
+++ branches/1.4/pbx/pbx_dundi.c Tue Jun 26 19:58:35 2007
@@ -51,6 +51,8 @@
 #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 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 @@
 	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 @@
 	char number[256];
 	int run;
 
-	for (;;) {
+	while (!dundi_shutdown) {
 		time(&now);
 		run = 0;
 		AST_LIST_LOCK(&pcq);
@@ -4461,9 +4465,18 @@
 {
 	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;




More information about the asterisk-commits mailing list