[svn-commits] trunk r24950 - /trunk/sched.c

svn-commits at lists.digium.com svn-commits at lists.digium.com
Mon May 8 04:10:55 MST 2006


Author: russell
Date: Fri May  5 13:11:55 2006
New Revision: 24950

URL: http://svn.digium.com/view/asterisk?rev=24950&view=rev
Log:
re-add the initialization of the scheduled item's time to 0.  I had removed
this because I checked the sched_alloc function to use calloc instead of
malloc, so I thought it was no longer necessary.  However, the sched structures
are cached, and cached values will have the old values in them, so this still
needs to be done.

Also, wrap the scheduler debug code to only happen if option_debug is enabled.
It spits out a ton of output so it's nice to be able to enable/disable it
during runtime.

Modified:
    trunk/sched.c

Modified: trunk/sched.c
URL: http://svn.digium.com/view/asterisk/trunk/sched.c?rev=24950&r1=24949&r2=24950&view=diff
==============================================================================
--- trunk/sched.c (original)
+++ trunk/sched.c Fri May  5 13:11:55 2006
@@ -24,7 +24,10 @@
  */
 
 #ifdef DEBUG_SCHEDULER
-#define DEBUG(a) DEBUG_M(a)
+#define DEBUG(a) do { \
+	if (option_debug) \
+		DEBUG_M(a) \
+	} while (0)
 #else
 #define DEBUG(a) 
 #endif
@@ -45,6 +48,7 @@
 #include "asterisk/lock.h"
 #include "asterisk/utils.h"
 #include "asterisk/linkedlists.h"
+#include "asterisk/options.h"
 
 /* Determine if a is sooner than b */
 #define SOONER(a,b) (((b).tv_sec > (a).tv_sec) || \
@@ -227,6 +231,7 @@
 		tmp->data = data;
 		tmp->resched = when;
 		tmp->variable = variable;
+		tmp->when = ast_tv(0, 0);
 		if (sched_settime(&tmp->when, when)) {
 			sched_release(con, tmp);
 		} else {
@@ -236,7 +241,8 @@
 	}
 #ifdef DUMP_SCHEDULER
 	/* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */
-	ast_sched_dump(con);
+	if (option_debug)
+		ast_sched_dump(con);
 #endif
 	ast_mutex_unlock(&con->lock);
 	return res;
@@ -272,7 +278,8 @@
 
 #ifdef DUMP_SCHEDULER
 	/* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */
-	ast_sched_dump(con);
+	if (option_debug)
+		ast_sched_dump(con);
 #endif
 	ast_mutex_unlock(&con->lock);
 
@@ -287,7 +294,7 @@
 	return 0;
 }
 
-/*! \brief Dump the contents of the scheduler to stderr */
+/*! \brief Dump the contents of the scheduler to LOG_DEBUG */
 void ast_sched_dump(const struct sched_context *con)
 {
 	struct sched *q;



More information about the svn-commits mailing list