summaryrefslogtreecommitdiff
path: root/pjlib/include
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 /pjlib/include
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 'pjlib/include')
-rw-r--r--pjlib/include/pj/config.h13
-rw-r--r--pjlib/include/pj/timer.h29
-rw-r--r--pjlib/include/pj/types.h5
3 files changed, 40 insertions, 7 deletions
diff --git a/pjlib/include/pj/config.h b/pjlib/include/pj/config.h
index 61249bef..c221a042 100644
--- a/pjlib/include/pj/config.h
+++ b/pjlib/include/pj/config.h
@@ -475,6 +475,19 @@
/**
+ * Enable timer heap debugging facility. When this is enabled, application
+ * can call pj_timer_heap_dump() to show the contents of the timer heap
+ * along with the source location where the timer entries were scheduled.
+ * See https://trac.pjsip.org/repos/ticket/1527 for more info.
+ *
+ * Default: 0
+ */
+#ifndef PJ_TIMER_DEBUG
+# define PJ_TIMER_DEBUG 0
+#endif
+
+
+/**
* Specify this as \a stack_size argument in #pj_thread_create() to specify
* that thread should use default stack size for the current platform.
*
diff --git a/pjlib/include/pj/timer.h b/pjlib/include/pj/timer.h
index 24d2bcb5..c2182ce3 100644
--- a/pjlib/include/pj/timer.h
+++ b/pjlib/include/pj/timer.h
@@ -85,7 +85,7 @@ typedef void pj_timer_heap_callback(pj_timer_heap_t *timer_heap,
/**
* This structure represents an entry to the timer.
*/
-struct pj_timer_entry
+typedef struct pj_timer_entry
{
/**
* User data to be associated with this entry.
@@ -117,7 +117,12 @@ struct pj_timer_entry
* by timer heap when the timer is scheduled.
*/
pj_time_val _timer_value;
-};
+
+#if PJ_TIMER_DEBUG
+ const char *src_file;
+ int src_line;
+#endif
+} pj_timer_entry;
/**
@@ -208,9 +213,20 @@ PJ_DECL(pj_timer_entry*) pj_timer_entry_init( pj_timer_entry *entry,
* @param delay The interval to expire.
* @return PJ_SUCCESS, or the appropriate error code.
*/
+#if PJ_TIMER_DEBUG
+# define pj_timer_heap_schedule(ht,e,d) \
+ pj_timer_heap_schedule_dbg(ht,e,d,__FILE__,__LINE__)
+
+ PJ_DECL(pj_status_t) pj_timer_heap_schedule_dbg( pj_timer_heap_t *ht,
+ pj_timer_entry *entry,
+ const pj_time_val *delay,
+ const char *src_file,
+ int src_line);
+#else
PJ_DECL(pj_status_t) pj_timer_heap_schedule( pj_timer_heap_t *ht,
pj_timer_entry *entry,
const pj_time_val *delay);
+#endif /* PJ_TIMER_DEBUG */
/**
* Cancel a previously registered timer.
@@ -262,6 +278,15 @@ PJ_DECL(pj_status_t) pj_timer_heap_earliest_time( pj_timer_heap_t *ht,
PJ_DECL(unsigned) pj_timer_heap_poll( pj_timer_heap_t *ht,
pj_time_val *next_delay);
+#if PJ_TIMER_DEBUG
+/**
+ * Dump timer heap entries.
+ *
+ * @param ht The timer heap.
+ */
+PJ_DECL(void) pj_timer_heap_dump(pj_timer_heap_t *ht);
+#endif
+
/**
* @}
*/
diff --git a/pjlib/include/pj/types.h b/pjlib/include/pj/types.h
index 1e434dd3..9f05ce44 100644
--- a/pjlib/include/pj/types.h
+++ b/pjlib/include/pj/types.h
@@ -213,11 +213,6 @@ typedef struct pj_ioqueue_key_t pj_ioqueue_key_t;
*/
typedef struct pj_timer_heap_t pj_timer_heap_t;
-/**
- * Forward declaration for timer entry.
- */
-typedef struct pj_timer_entry pj_timer_entry;
-
/**
* Opaque data type for atomic operations.
*/