[Asterisk-cvs] asterisk/channels chan_mgcp.c,1.46,1.47

markster at lists.digium.com markster at lists.digium.com
Tue Apr 27 17:11:42 CDT 2004


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

Modified Files:
	chan_mgcp.c 
Log Message:
Improve responsiveness of MGCP during a reload (bug #1488)


Index: chan_mgcp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_mgcp.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- chan_mgcp.c	26 Apr 2004 05:18:55 -0000	1.46
+++ chan_mgcp.c	27 Apr 2004 21:18:02 -0000	1.47
@@ -44,6 +44,9 @@
    -- enhance retransmit mechanism (RTO calc. etc.)
    -- embedded command support
 */
+/* FS: Changes
+ * -- fixed reload_config() / do_monitor to stay responsive during reloads
+ */
 
 #include <stdio.h>
 #include <pthread.h>
@@ -3116,6 +3119,8 @@
 	return 1;
 }
 
+static int *mgcpsock_read_id = NULL;
+
 static void *do_monitor(void *data)
 {
 	int res;
@@ -3126,7 +3131,7 @@
 
 	/* Add an I/O event to our UDP socket */
 	if (mgcpsock > -1) 
-		ast_io_add(io, mgcpsock, mgcpsock_read, AST_IO_IN, NULL);
+		mgcpsock_read_id = ast_io_add(io, mgcpsock, mgcpsock_read, AST_IO_IN, NULL);
 	
 	/* This thread monitors all the frame relay interfaces which are not yet in use
 	   (and thus do not have a separate thread) indefinitely */
@@ -3865,22 +3870,28 @@
 	cat = ast_category_browse(cfg, NULL);
 	while(cat) {
 		if (strcasecmp(cat, "general")) {
-            ast_mutex_lock(&gatelock);
+	    	ast_mutex_lock(&gatelock);
 			g = build_gateway(cat, ast_variable_browse(cfg, cat));
 			if (g) {
 				if (option_verbose > 2) {
 					ast_verbose(VERBOSE_PREFIX_3 "Added gateway '%s'\n", g->name);
-                }
-                g->next = gateways;
-                gateways = g;
+				}
+				g->next = gateways;
+				gateways = g;
+			}
+	    	ast_mutex_unlock(&gatelock);
+
+			/* FS: process queue and IO */
+			if (monitor_thread == pthread_self()) {
+				if (sched) ast_sched_runq(sched);
+				if (io) ast_io_wait(io, 10);
 			}
-            ast_mutex_unlock(&gatelock);
 		}
 		cat = ast_category_browse(cfg, cat);
 	}
 
-    /* SC: prune deleted entries etc. */
-    prune_gateways();
+    	/* SC: prune deleted entries etc. */
+    	prune_gateways();
 
 	if (ntohl(bindaddr.sin_addr.s_addr)) {
 		memcpy(&__ourip, &bindaddr.sin_addr, sizeof(__ourip));
@@ -3899,6 +3910,10 @@
 	ast_mutex_lock(&netlock);
 	if (mgcpsock > -1)
 		close(mgcpsock);
+
+	if (mgcpsock_read_id != NULL)
+		mgcpsock_read_id = ast_io_remove(io, mgcpsock_read_id);
+
 	mgcpsock = socket(AF_INET, SOCK_DGRAM, 0);
 	if (mgcpsock < 0) {
 		ast_log(LOG_WARNING, "Unable to create MGCP socket: %s\n", strerror(errno));




More information about the svn-commits mailing list