[Asterisk-cvs] asterisk/channels chan_h323.c,1.26,1.27

jeremy at lists.digium.com jeremy at lists.digium.com
Mon Jan 12 21:15:28 CST 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv23107

Modified Files:
	chan_h323.c 
Log Message:
Fix it so we can be unloaded/loaded at will


Index: chan_h323.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_h323.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- chan_h323.c	11 Jan 2004 17:51:35 -0000	1.26
+++ chan_h323.c	13 Jan 2004 03:07:15 -0000	1.27
@@ -1270,7 +1270,7 @@
 		ast_log(LOG_WARNING, "Cannot kill myself\n");
 		return -1;
 	}
-	if (monitor_thread) {
+	if (monitor_thread && (monitor_thread != -2)) {
 		/* Wake up the thread */
 		pthread_kill(monitor_thread, SIGURG);
 	} else {
@@ -1786,11 +1786,12 @@
 		
 		/* Register our callback functions */
 		h323_callback_register(setup_incoming_call, 
-							   setup_outgoing_call,							 
-							   create_connection, 
-							   setup_rtp_connection, 
-							   cleanup_connection, 
-							   connection_made, send_digit);	
+			               setup_outgoing_call,							 
+	 			       create_connection, 
+				       setup_rtp_connection, 
+				       cleanup_connection, 
+				       connection_made, 
+				       send_digit);	
 	
 
 		/* start the h.323 listener */
@@ -1833,6 +1834,19 @@
 		ast_log(LOG_WARNING, "Unable to lock the interface list\n");
 		return -1;
 	}
+
+	if (!ast_mutex_lock(&monlock)) {
+                if (monitor_thread && (monitor_thread != -2)) {
+                        pthread_cancel(monitor_thread);
+                        pthread_kill(monitor_thread, SIGURG);
+                        pthread_join(monitor_thread, NULL);
+                 }
+                monitor_thread = (pthread_t) -2;
+                ast_mutex_unlock(&monlock);
+        } else {
+                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
+                return -1;
+        }
 		
 	if (!ast_mutex_lock(&iflock)) {
 		/* destroy all the interfaces and free their memory */
@@ -1856,13 +1870,15 @@
 	ast_rtp_proto_unregister(&oh323_rtp);
 	
 	/* unregister commands */
-	ast_cli_unregister(&cli_debug);
-	ast_cli_unregister(&cli_no_debug);
-	ast_cli_unregister(&cli_trace);
-	ast_cli_unregister(&cli_no_trace);
-	ast_cli_unregister(&cli_show_codecs);
-	ast_cli_unregister(&cli_gk_cycle);
-
+        ast_cli_unregister(&cli_debug);
+        ast_cli_unregister(&cli_no_debug);
+        ast_cli_unregister(&cli_trace);
+        ast_cli_unregister(&cli_no_trace);   
+        ast_cli_unregister(&cli_show_codecs);
+//      ast_cli_unregister(&cli_gk_cycle);
+        ast_cli_unregister(&cli_hangup_call);
+        ast_cli_unregister(&cli_show_tokens);
+                        
 	/* unregister channel type */
 	ast_channel_unregister(type);
 




More information about the svn-commits mailing list