[svn-commits] russell: branch russell/res_monkeys r81366 - /team/russell/res_monkeys/main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Aug 29 18:45:43 CDT 2007


Author: russell
Date: Wed Aug 29 18:45:42 2007
New Revision: 81366

URL: http://svn.digium.com/view/asterisk?view=rev&rev=81366
Log:
Make the channel scheduler context a lot more useful than it was before.
Previously, it was only used when streaming files, I think.  Now, code should
be able to add callbacks to the channel scheduler and have them work under
any normal circumstances.

Checking the time until the next callback has been integrated into the
ast_waitfor() core, and ast_waitfor() will return a channel if it has callbacks
that need to get executed.  ast_read() will check to see if it is time to
execute any callbacks and will do so if it is time.

Modified:
    team/russell/res_monkeys/main/channel.c

Modified: team/russell/res_monkeys/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/res_monkeys/main/channel.c?view=diff&rev=81366&r1=81365&r2=81366
==============================================================================
--- team/russell/res_monkeys/main/channel.c (original)
+++ team/russell/res_monkeys/main/channel.c Wed Aug 29 18:45:42 2007
@@ -1621,6 +1621,7 @@
 		int chan;
 		int fdno;
 	} *fdmap;
+	int sched_ms = 0;
 
 	sz = n * AST_MAX_FDS + nfds;
 	pfds = alloca(sizeof(*pfds) * sz);
@@ -1633,6 +1634,7 @@
 	
 	/* Perform any pending masquerades */
 	for (x = 0; x < n; x++) {
+		int chan_sched_ms;
 		ast_channel_lock(c[x]);
 		if (c[x]->masq && ast_do_masquerade(c[x])) {
 			ast_log(LOG_WARNING, "Masquerade failed\n");
@@ -1653,6 +1655,16 @@
 			if (!whentohangup || (diff < whentohangup))
 				whentohangup = diff;
 		}
+		chan_sched_ms = ast_sched_wait(c[x]->sched);
+		if (chan_sched_ms > -1) {
+			if (!chan_sched_ms) {
+				/* This channel has a scheduler item to run */
+				ast_channel_unlock(c[x]);
+				return c[x];
+			}
+			if (chan_sched_ms > sched_ms)
+				sched_ms = chan_sched_ms;
+		}
 		ast_channel_unlock(c[x]);
 	}
 	/* Wait full interval */
@@ -1662,6 +1674,8 @@
 		if (*ms >= 0 && *ms < rms)		/* original *ms still smaller */
 			rms =  *ms;
 	}
+	if (sched_ms && sched_ms < rms)
+		rms = sched_ms;
 	/*
 	 * Build the pollfd array, putting the channels' fds first,
 	 * followed by individual fds. Order is important because
@@ -2126,6 +2140,11 @@
 		goto done;
 	}
 	prestate = chan->_state;
+
+	if (!ast_sched_wait(chan->sched)) {
+		/* There is something ready on the channel's scheduler context */
+		ast_sched_runq(chan->sched);
+	}
 
 	if (!ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_EMULATE_DTMF | AST_FLAG_IN_DTMF) && 
 	    !ast_strlen_zero(chan->dtmfq) && 




More information about the svn-commits mailing list