[asterisk-commits] russell: trunk r175882 - in /trunk: include/asterisk/sched.h main/sched.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Feb 15 15:27:34 CST 2009
Author: russell
Date: Sun Feb 15 15:27:33 2009
New Revision: 175882
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=175882
Log:
Make ast_sched_report() and ast_sched_dump() thread safe.
Modified:
trunk/include/asterisk/sched.h
trunk/main/sched.c
Modified: trunk/include/asterisk/sched.h
URL: http://svn.digium.com/svn-view/asterisk/trunk/include/asterisk/sched.h?view=diff&rev=175882&r1=175881&r2=175882
==============================================================================
--- trunk/include/asterisk/sched.h (original)
+++ trunk/include/asterisk/sched.h Sun Feb 15 15:27:33 2009
@@ -257,7 +257,7 @@
* Debugging: Dump the contents of the scheduler to stderr
* \param con Context to dump
*/
-void ast_sched_dump(const struct sched_context *con);
+void ast_sched_dump(struct sched_context *con);
/*! \brief Returns the number of seconds before an event takes place
* \param con Context to use
Modified: trunk/main/sched.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/main/sched.c?view=diff&rev=175882&r1=175881&r2=175882
==============================================================================
--- trunk/main/sched.c (original)
+++ trunk/main/sched.c Sun Feb 15 15:27:33 2009
@@ -536,6 +536,7 @@
ast_str_set(buf, 0, " Highwater = %d\n schedcnt = %d\n", con->highwater, con->schedcnt);
+ ast_mutex_lock(&con->lock);
AST_DLLIST_TRAVERSE(&con->schedq, cur, list) {
/* match the callback to the cblist */
for (i = 0; i < cbnames->numassocs; i++) {
@@ -549,6 +550,7 @@
countlist[cbnames->numassocs]++;
}
}
+ ast_mutex_unlock(&con->lock);
for (i = 0; i < cbnames->numassocs; i++) {
ast_str_append(buf, 0, " %s : %d\n", cbnames->list[i], countlist[i]);
@@ -558,7 +560,7 @@
}
/*! \brief Dump the contents of the scheduler to LOG_DEBUG */
-void ast_sched_dump(const struct sched_context *con)
+void ast_sched_dump(struct sched_context *con)
{
struct sched *q;
struct timeval when = ast_tvnow();
@@ -571,6 +573,7 @@
ast_debug(1, "=============================================================\n");
ast_debug(1, "|ID Callback Data Time (sec:ms) |\n");
ast_debug(1, "+-----+-----------------+-----------------+-----------------+\n");
+ ast_mutex_lock(&con->lock);
AST_DLLIST_TRAVERSE(&con->schedq, q, list) {
struct timeval delta = ast_tvsub(q->when, when);
@@ -581,8 +584,8 @@
(long)delta.tv_sec,
(long int)delta.tv_usec);
}
+ ast_mutex_unlock(&con->lock);
ast_debug(1, "=============================================================\n");
-
}
/*! \brief
More information about the asterisk-commits
mailing list