[asterisk-commits] russell: branch russell/autoservice-nochans-1.4 r105553 - in /team/russell/au...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Mar 2 03:42:01 CST 2008


Author: russell
Date: Sun Mar  2 03:42:00 2008
New Revision: 105553

URL: http://svn.digium.com/view/asterisk?view=rev&rev=105553
Log:
Previously, if there were no channels in autoservice, the AS thread would run
in a loop calling ast_waitfor_n() twice a second, with no channels to poll on.
This makes the code more sane and has it use a thread condition.

(inspired by and related to issue #12116)

Modified:
    team/russell/autoservice-nochans-1.4/include/asterisk.h
    team/russell/autoservice-nochans-1.4/main/asterisk.c
    team/russell/autoservice-nochans-1.4/main/autoservice.c

Modified: team/russell/autoservice-nochans-1.4/include/asterisk.h
URL: http://svn.digium.com/view/asterisk/team/russell/autoservice-nochans-1.4/include/asterisk.h?view=diff&rev=105553&r1=105552&r2=105553
==============================================================================
--- team/russell/autoservice-nochans-1.4/include/asterisk.h (original)
+++ team/russell/autoservice-nochans-1.4/include/asterisk.h Sun Mar  2 03:42:00 2008
@@ -75,6 +75,7 @@
 int dnsmgr_reload(void);			/*!< Provided by dnsmgr.c */
 void threadstorage_init(void);			/*!< Provided by threadstorage.c */
 int astobj2_init(void);				/*! Provided by astobj2.c */
+void ast_autoservice_init(void);    /*!< Provided by autoservice.c */
 
 /* Many headers need 'ast_channel' to be defined */
 struct ast_channel;

Modified: team/russell/autoservice-nochans-1.4/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/russell/autoservice-nochans-1.4/main/asterisk.c?view=diff&rev=105553&r1=105552&r2=105553
==============================================================================
--- team/russell/autoservice-nochans-1.4/main/asterisk.c (original)
+++ team/russell/autoservice-nochans-1.4/main/asterisk.c Sun Mar  2 03:42:00 2008
@@ -2896,6 +2896,8 @@
 
 	astobj2_init();
 
+	ast_autoservice_init();
+
 	if (load_modules(1)) {
 		printf(term_quit());
 		exit(1);

Modified: team/russell/autoservice-nochans-1.4/main/autoservice.c
URL: http://svn.digium.com/view/asterisk/team/russell/autoservice-nochans-1.4/main/autoservice.c?view=diff&rev=105553&r1=105552&r2=105553
==============================================================================
--- team/russell/autoservice-nochans-1.4/main/autoservice.c (original)
+++ team/russell/autoservice-nochans-1.4/main/autoservice.c Sun Mar  2 03:42:00 2008
@@ -64,6 +64,7 @@
 };
 
 static AST_LIST_HEAD_STATIC(aslist, asent);
+static ast_cond_t as_cond;
 
 static pthread_t asthread = AST_PTHREADT_NULL;
 
@@ -97,6 +98,9 @@
 		/* At this point, we know that no channels that have been removed are going
 		 * to get used again. */
 		as_chan_list_state++;
+
+		if (AST_LIST_EMPTY(&aslist))
+			ast_cond_wait(&as_cond, &aslist.lock);
 
 		AST_LIST_TRAVERSE(&aslist, as, list) {
 			if (!as->chan->_softhangup) {
@@ -106,6 +110,7 @@
 					ast_log(LOG_WARNING, "Exceeded maximum number of automatic monitoring events.  Fix autoservice.c\n");
 			}
 		}
+
 		AST_LIST_UNLOCK(&aslist);
 
 		chan = ast_waitfor_n(mons, x, &ms);
@@ -194,6 +199,8 @@
 	ast_channel_unlock(chan);
 
 	AST_LIST_LOCK(&aslist);
+	if (AST_LIST_EMPTY(&aslist))
+		ast_cond_signal(&as_cond);
 	AST_LIST_INSERT_HEAD(&aslist, as, list);
 	AST_LIST_UNLOCK(&aslist);
 
@@ -276,3 +283,8 @@
 
 	return res;
 }
+
+void ast_autoservice_init(void)
+{
+	ast_cond_init(&as_cond, NULL);
+}




More information about the asterisk-commits mailing list