summaryrefslogtreecommitdiff
path: root/pjsip/src
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2012-06-05 10:41:17 +0000
committerBenny Prijono <bennylp@teluu.com>2012-06-05 10:41:17 +0000
commit2ffba2873e85bb5c7f9fcb025f9c28c4bb738b48 (patch)
tree58e68be64c103e4e60e52c18e6df477ca3375f72 /pjsip/src
parent1511db342e293b00656fcde74992d02b3c42046f (diff)
Re #1527: added debugging facility to the timer heap. By enabling PJ_TIMER_DEBUG, application can use pj_timer_heap_dump() or pjsip_endpt_dump() to dump the timer entries along with the source location where it is scheduled from. The macro will also enable dumping the timer heap entries when the SIP endpoint is being destroyed
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4154 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src')
-rw-r--r--pjsip/src/pjsip/sip_endpoint.c21
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c24
2 files changed, 45 insertions, 0 deletions
diff --git a/pjsip/src/pjsip/sip_endpoint.c b/pjsip/src/pjsip/sip_endpoint.c
index 3eb865b1..b1d7f7d2 100644
--- a/pjsip/src/pjsip/sip_endpoint.c
+++ b/pjsip/src/pjsip/sip_endpoint.c
@@ -606,6 +606,9 @@ PJ_DEF(void) pjsip_endpt_destroy(pjsip_endpoint *endpt)
pj_ioqueue_destroy(endpt->ioqueue);
/* Destroy timer heap */
+#if PJ_TIMER_DEBUG
+ pj_timer_heap_dump(endpt->timer_heap);
+#endif
pj_timer_heap_destroy(endpt->timer_heap);
/* Call all registered exit callbacks */
@@ -768,6 +771,19 @@ PJ_DEF(pj_status_t) pjsip_endpt_handle_events(pjsip_endpoint *endpt,
/*
* Schedule timer.
*/
+#if PJ_TIMER_DEBUG
+PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer_dbg(pjsip_endpoint *endpt,
+ pj_timer_entry *entry,
+ const pj_time_val *delay,
+ const char *src_file,
+ int src_line)
+{
+ PJ_LOG(6, (THIS_FILE, "pjsip_endpt_schedule_timer(entry=%p, delay=%u.%u)",
+ entry, delay->sec, delay->msec));
+ return pj_timer_heap_schedule_dbg(endpt->timer_heap, entry, delay,
+ src_file, src_line);
+}
+#else
PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer( pjsip_endpoint *endpt,
pj_timer_entry *entry,
const pj_time_val *delay )
@@ -776,6 +792,7 @@ PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer( pjsip_endpoint *endpt,
entry, delay->sec, delay->msec));
return pj_timer_heap_schedule( endpt->timer_heap, entry, delay );
}
+#endif
/*
* Cancel the previously registered timer.
@@ -1193,8 +1210,12 @@ PJ_DEF(void) pjsip_endpt_dump( pjsip_endpoint *endpt, pj_bool_t detail )
pjsip_tpmgr_dump_transports( endpt->transport_mgr );
/* Timer. */
+#if PJ_TIMER_DEBUG
+ pj_timer_heap_dump(endpt->timer_heap);
+#else
PJ_LOG(3,(THIS_FILE, " Timer heap has %u entries",
pj_timer_heap_count(endpt->timer_heap)));
+#endif
/* Unlock mutex. */
pj_mutex_unlock(endpt->mutex);
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 1e4bc7ff..5c0ecc3b 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -2623,11 +2623,22 @@ PJ_DEF(pj_status_t) pjsua_verify_sip_url(const char *c_url)
/*
* Schedule a timer entry.
*/
+#if PJ_TIMER_DEBUG
+PJ_DEF(pj_status_t) pjsua_schedule_timer_dbg( pj_timer_entry *entry,
+ const pj_time_val *delay,
+ const char *src_file,
+ int src_line)
+{
+ return pjsip_endpt_schedule_timer_dbg(pjsua_var.endpt, entry, delay,
+ src_file, src_line);
+}
+#else
PJ_DEF(pj_status_t) pjsua_schedule_timer( pj_timer_entry *entry,
const pj_time_val *delay)
{
return pjsip_endpt_schedule_timer(pjsua_var.endpt, entry, delay);
}
+#endif
/* Timer callback */
static void timer_cb( pj_timer_heap_t *th,
@@ -2650,9 +2661,17 @@ static void timer_cb( pj_timer_heap_t *th,
/*
* Schedule a timer callback.
*/
+#if PJ_TIMER_DEBUG
+PJ_DEF(pj_status_t) pjsua_schedule_timer2_dbg( void (*cb)(void *user_data),
+ void *user_data,
+ unsigned msec_delay,
+ const char *src_file,
+ int src_line)
+#else
PJ_DEF(pj_status_t) pjsua_schedule_timer2( void (*cb)(void *user_data),
void *user_data,
unsigned msec_delay)
+#endif
{
pjsua_timer_list *tmr = NULL;
pj_status_t status;
@@ -2672,7 +2691,12 @@ PJ_DEF(pj_status_t) pjsua_schedule_timer2( void (*cb)(void *user_data),
delay.sec = 0;
delay.msec = msec_delay;
+#if PJ_TIMER_DEBUG
+ status = pjsip_endpt_schedule_timer_dbg(pjsua_var.endpt, &tmr->entry,
+ &delay, src_file, src_line);
+#else
status = pjsip_endpt_schedule_timer(pjsua_var.endpt, &tmr->entry, &delay);
+#endif
if (status != PJ_SUCCESS) {
pj_list_push_back(&pjsua_var.timer_list, tmr);
}