<p>Richard Mudgett has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8756">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjsip_scheduler.c: Add ability to trace scheduled tasks.<br><br>When a scheduled task is created you can pass in the<br>AST_SIP_SCHED_TASK_TRACK flag. This new flag causes scheduling events to<br>be logged.<br><br>Change-Id: I91967eb3d5a220915ce86881a28af772f9a7f56b<br>---<br>M include/asterisk/res_pjsip.h<br>M res/res_pjsip/pjsip_scheduler.c<br>2 files changed, 32 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/56/8756/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h<br>index b01d6f5..f06aec4 100644<br>--- a/include/asterisk/res_pjsip.h<br>+++ b/include/asterisk/res_pjsip.h<br>@@ -1620,16 +1620,23 @@<br> */<br> AST_SIP_SCHED_TASK_DATA_FREE = ( 1 << 3 ),<br> <br>- /*! \brief AST_SIP_SCHED_TASK_PERIODIC<br>- * The task is scheduled at multiples of interval<br>+ /*!<br>+ * \brief The task is scheduled at multiples of interval<br> * \see Interval<br> */<br> AST_SIP_SCHED_TASK_PERIODIC = (0 << 4),<br>- /*! \brief AST_SIP_SCHED_TASK_DELAY<br>- * The next invocation of the task is at last finish + interval<br>+ /*!<br>+ * \brief The next invocation of the task is at last finish + interval<br> * \see Interval<br> */<br> AST_SIP_SCHED_TASK_DELAY = (1 << 4),<br>+ /*!<br>+ * \brief The scheduled task's events are tracked in the debug log.<br>+ * \details<br>+ * Schedule events such as scheduling, running, rescheduling, canceling,<br>+ * and destroying are logged about the task.<br>+ */<br>+ AST_SIP_SCHED_TASK_TRACK = (1 << 5),<br> };<br> <br> /*!<br>diff --git a/res/res_pjsip/pjsip_scheduler.c b/res/res_pjsip/pjsip_scheduler.c<br>index 4210664..65dd6e1 100644<br>--- a/res/res_pjsip/pjsip_scheduler.c<br>+++ b/res/res_pjsip/pjsip_scheduler.c<br>@@ -86,6 +86,9 @@<br> return -1;<br> }<br> <br>+ if (schtd->flags & AST_SIP_SCHED_TASK_TRACK) {<br>+ ast_log(LOG_DEBUG, "Sched %p: Running %s\n", schtd, schtd->name);<br>+ }<br> ao2_lock(schtd);<br> schtd->last_start = ast_tvnow();<br> schtd->is_running = 1;<br>@@ -137,6 +140,10 @@<br> }<br> <br> ao2_unlock(schtd);<br>+ if (schtd->flags & AST_SIP_SCHED_TASK_TRACK) {<br>+ ast_log(LOG_DEBUG, "Sched %p: Rescheduled %s for %d ms\n", schtd, schtd->name,<br>+ delay);<br>+ }<br> <br> return 0;<br> }<br>@@ -159,6 +166,9 @@<br> return 0;<br> }<br> <br>+ if (schtd->flags & AST_SIP_SCHED_TASK_TRACK) {<br>+ ast_log(LOG_DEBUG, "Sched %p: Ready to run %s\n", schtd, schtd->name);<br>+ }<br> ao2_t_ref(schtd, +1, "Give ref to run_task()");<br> if (ast_sip_push_task(schtd->serializer, run_task, schtd)) {<br> /*<br>@@ -180,6 +190,10 @@<br> {<br> int res;<br> int sched_id;<br>+<br>+ if (schtd->flags & AST_SIP_SCHED_TASK_TRACK) {<br>+ ast_log(LOG_DEBUG, "Sched %p: Canceling %s\n", schtd, schtd->name);<br>+ }<br> <br> /*<br> * Prevent any tasks in the serializer queue from<br>@@ -347,6 +361,9 @@<br> {<br> struct ast_sip_sched_task *schtd = data;<br> <br>+ if (schtd->flags & AST_SIP_SCHED_TASK_TRACK) {<br>+ ast_log(LOG_DEBUG, "Sched %p: Destructor %s\n", schtd, schtd->name);<br>+ }<br> if (schtd->flags & AST_SIP_SCHED_TASK_DATA_AO2) {<br> /* release our own ref, then release the callers if asked to do so */<br> ao2_ref(schtd->task_data, (schtd->flags & AST_SIP_SCHED_TASK_DATA_FREE) ? -2 : -1);<br>@@ -387,6 +404,10 @@<br> task_id = ast_atomic_fetchadd_int(&task_count, 1);<br> sprintf(schtd->name, "task_%08x", task_id);<br> }<br>+ if (schtd->flags & AST_SIP_SCHED_TASK_TRACK) {<br>+ ast_log(LOG_DEBUG, "Sched %p: Scheduling %s for %d ms\n", schtd, schtd->name,<br>+ interval);<br>+ }<br> schtd->when_queued = ast_tvnow();<br> if (!(schtd->flags & AST_SIP_SCHED_TASK_DELAY)) {<br> schtd->next_periodic = ast_tvadd(schtd->when_queued,<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8756">change 8756</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8756"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I91967eb3d5a220915ce86881a28af772f9a7f56b </div>
<div style="display:none"> Gerrit-Change-Number: 8756 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Richard Mudgett <rmudgett@digium.com> </div>