Changeset 4154 for pjproject/trunk
- Timestamp:
- Jun 5, 2012 10:41:17 AM (12 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/config.h
r4141 r4154 472 472 #ifndef PJ_POOL_DEBUG 473 473 # define PJ_POOL_DEBUG 0 474 #endif 475 476 477 /** 478 * Enable timer heap debugging facility. When this is enabled, application 479 * can call pj_timer_heap_dump() to show the contents of the timer heap 480 * along with the source location where the timer entries were scheduled. 481 * See https://trac.pjsip.org/repos/ticket/1527 for more info. 482 * 483 * Default: 0 484 */ 485 #ifndef PJ_TIMER_DEBUG 486 # define PJ_TIMER_DEBUG 0 474 487 #endif 475 488 -
pjproject/trunk/pjlib/include/pj/timer.h
r3034 r4154 86 86 * This structure represents an entry to the timer. 87 87 */ 88 struct pj_timer_entry88 typedef struct pj_timer_entry 89 89 { 90 90 /** … … 118 118 */ 119 119 pj_time_val _timer_value; 120 }; 120 121 #if PJ_TIMER_DEBUG 122 const char *src_file; 123 int src_line; 124 #endif 125 } pj_timer_entry; 121 126 122 127 … … 209 214 * @return PJ_SUCCESS, or the appropriate error code. 210 215 */ 216 #if PJ_TIMER_DEBUG 217 # define pj_timer_heap_schedule(ht,e,d) \ 218 pj_timer_heap_schedule_dbg(ht,e,d,__FILE__,__LINE__) 219 220 PJ_DECL(pj_status_t) pj_timer_heap_schedule_dbg( pj_timer_heap_t *ht, 221 pj_timer_entry *entry, 222 const pj_time_val *delay, 223 const char *src_file, 224 int src_line); 225 #else 211 226 PJ_DECL(pj_status_t) pj_timer_heap_schedule( pj_timer_heap_t *ht, 212 227 pj_timer_entry *entry, 213 228 const pj_time_val *delay); 229 #endif /* PJ_TIMER_DEBUG */ 214 230 215 231 /** … … 263 279 pj_time_val *next_delay); 264 280 281 #if PJ_TIMER_DEBUG 282 /** 283 * Dump timer heap entries. 284 * 285 * @param ht The timer heap. 286 */ 287 PJ_DECL(void) pj_timer_heap_dump(pj_timer_heap_t *ht); 288 #endif 289 265 290 /** 266 291 * @} -
pjproject/trunk/pjlib/include/pj/types.h
r3999 r4154 214 214 typedef struct pj_timer_heap_t pj_timer_heap_t; 215 215 216 /**217 * Forward declaration for timer entry.218 */219 typedef struct pj_timer_entry pj_timer_entry;220 221 216 /** 222 217 * Opaque data type for atomic operations. -
pjproject/trunk/pjlib/src/pj/timer.c
r3456 r4154 35 35 #include <pj/errno.h> 36 36 #include <pj/lock.h> 37 #include <pj/log.h> 38 39 #define THIS_FILE "timer.c" 37 40 38 41 #define HEAP_PARENT(X) (X == 0 ? 0 : (((X) - 1) / 2)) … … 453 456 } 454 457 458 #if PJ_TIMER_DEBUG 459 PJ_DEF(pj_status_t) pj_timer_heap_schedule_dbg( pj_timer_heap_t *ht, 460 pj_timer_entry *entry, 461 const pj_time_val *delay, 462 const char *src_file, 463 int src_line) 464 #else 455 465 PJ_DEF(pj_status_t) pj_timer_heap_schedule( pj_timer_heap_t *ht, 456 466 pj_timer_entry *entry, 457 467 const pj_time_val *delay) 468 #endif 458 469 { 459 470 pj_status_t status; … … 466 477 PJ_ASSERT_RETURN(entry->_timer_id < 1, PJ_EINVALIDOP); 467 478 479 #if PJ_TIMER_DEBUG 480 entry->src_file = src_file; 481 entry->src_line = src_line; 482 #endif 468 483 pj_gettickcount(&expires); 469 484 PJ_TIME_VAL_ADD(expires, *delay); … … 553 568 } 554 569 570 #if PJ_TIMER_DEBUG 571 PJ_DEF(void) pj_timer_heap_dump(pj_timer_heap_t *ht) 572 { 573 lock_timer_heap(ht); 574 575 PJ_LOG(3,(THIS_FILE, "Dumping timer heap:")); 576 PJ_LOG(3,(THIS_FILE, " Cur size: %d entries, max: %d", 577 (int)ht->cur_size, (int)ht->max_size)); 578 579 if (ht->cur_size) { 580 unsigned i; 581 pj_time_val now; 582 583 PJ_LOG(3,(THIS_FILE, " Entries: ")); 584 PJ_LOG(3,(THIS_FILE, " _id\tId\tElapsed\tSource")); 585 PJ_LOG(3,(THIS_FILE, " ----------------------------------")); 586 587 pj_gettickcount(&now); 588 589 for (i=0; i<(unsigned)ht->cur_size; ++i) { 590 pj_timer_entry *e = ht->heap[i]; 591 pj_time_val delta; 592 593 if (PJ_TIME_VAL_LTE(e->_timer_value, now)) 594 delta.sec = delta.msec = 0; 595 else { 596 delta = e->_timer_value; 597 PJ_TIME_VAL_SUB(delta, now); 598 } 599 600 PJ_LOG(3,(THIS_FILE, " %d\t%d\t%d.%03d\t%s:%d", 601 e->_timer_id, e->id, 602 (int)delta.sec, (int)delta.msec, 603 e->src_file, e->src_line)); 604 } 605 } 606 607 unlock_timer_heap(ht); 608 } 609 #endif 610 -
pjproject/trunk/pjsip/include/pjsip/sip_endpoint.h
r3999 r4154 151 151 * @return PJ_OK (zero) if successfull. 152 152 */ 153 #if PJ_TIMER_DEBUG 154 #define pjsip_endpt_schedule_timer(ept,ent,d) \ 155 pjsip_endpt_schedule_timer_dbg(ept, ent, d, \ 156 __FILE__, __LINE__) 157 158 PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer_dbg(pjsip_endpoint *endpt, 159 pj_timer_entry *entry, 160 const pj_time_val *delay, 161 const char *src_file, 162 int src_line); 163 #else 153 164 PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer( pjsip_endpoint *endpt, 154 165 pj_timer_entry *entry, 155 166 const pj_time_val *delay ); 167 #endif 156 168 157 169 /** -
pjproject/trunk/pjsip/include/pjsip/sip_event.h
r3553 r4154 35 35 */ 36 36 #include <pj/types.h> 37 #include <pj/timer.h> 37 38 38 39 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r4138 r4154 2020 2020 * @see pjsip_endpt_schedule_timer() 2021 2021 */ 2022 #if PJ_TIMER_DEBUG 2023 #define pjsua_schedule_timer(e,d) pjsua_schedule_timer_dbg(e,d,\ 2024 __FILE__,__LINE__) 2025 2026 PJ_DECL(pj_status_t) pjsua_schedule_timer_dbg(pj_timer_entry *entry, 2027 const pj_time_val *delay, 2028 const char *src_file, 2029 int src_line); 2030 #else 2022 2031 PJ_DECL(pj_status_t) pjsua_schedule_timer(pj_timer_entry *entry, 2023 2032 const pj_time_val *delay); 2033 #endif 2024 2034 2025 2035 /** … … 2034 2044 * @return PJ_SUCCESS on success, or the appropriate error code. 2035 2045 */ 2046 #if PJ_TIMER_DEBUG 2047 #define pjsua_schedule_timer2(cb,u,d) \ 2048 pjsua_schedule_timer2_dbg(cb,u,d,__FILE__,__LINE__) 2049 2050 PJ_DECL(pj_status_t) pjsua_schedule_timer2_dbg(void (*cb)(void *user_data), 2051 void *user_data, 2052 unsigned msec_delay, 2053 const char *src_file, 2054 int src_line); 2055 #else 2036 2056 PJ_DECL(pj_status_t) pjsua_schedule_timer2(void (*cb)(void *user_data), 2037 2057 void *user_data, 2038 2058 unsigned msec_delay); 2059 #endif 2039 2060 2040 2061 /** -
pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c
r3999 r4154 607 607 608 608 /* Destroy timer heap */ 609 #if PJ_TIMER_DEBUG 610 pj_timer_heap_dump(endpt->timer_heap); 611 #endif 609 612 pj_timer_heap_destroy(endpt->timer_heap); 610 613 … … 769 772 * Schedule timer. 770 773 */ 774 #if PJ_TIMER_DEBUG 775 PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer_dbg(pjsip_endpoint *endpt, 776 pj_timer_entry *entry, 777 const pj_time_val *delay, 778 const char *src_file, 779 int src_line) 780 { 781 PJ_LOG(6, (THIS_FILE, "pjsip_endpt_schedule_timer(entry=%p, delay=%u.%u)", 782 entry, delay->sec, delay->msec)); 783 return pj_timer_heap_schedule_dbg(endpt->timer_heap, entry, delay, 784 src_file, src_line); 785 } 786 #else 771 787 PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer( pjsip_endpoint *endpt, 772 788 pj_timer_entry *entry, … … 777 793 return pj_timer_heap_schedule( endpt->timer_heap, entry, delay ); 778 794 } 795 #endif 779 796 780 797 /* … … 1194 1211 1195 1212 /* Timer. */ 1213 #if PJ_TIMER_DEBUG 1214 pj_timer_heap_dump(endpt->timer_heap); 1215 #else 1196 1216 PJ_LOG(3,(THIS_FILE, " Timer heap has %u entries", 1197 1217 pj_timer_heap_count(endpt->timer_heap))); 1218 #endif 1198 1219 1199 1220 /* Unlock mutex. */ -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r4122 r4154 2624 2624 * Schedule a timer entry. 2625 2625 */ 2626 #if PJ_TIMER_DEBUG 2627 PJ_DEF(pj_status_t) pjsua_schedule_timer_dbg( pj_timer_entry *entry, 2628 const pj_time_val *delay, 2629 const char *src_file, 2630 int src_line) 2631 { 2632 return pjsip_endpt_schedule_timer_dbg(pjsua_var.endpt, entry, delay, 2633 src_file, src_line); 2634 } 2635 #else 2626 2636 PJ_DEF(pj_status_t) pjsua_schedule_timer( pj_timer_entry *entry, 2627 2637 const pj_time_val *delay) … … 2629 2639 return pjsip_endpt_schedule_timer(pjsua_var.endpt, entry, delay); 2630 2640 } 2641 #endif 2631 2642 2632 2643 /* Timer callback */ … … 2651 2662 * Schedule a timer callback. 2652 2663 */ 2664 #if PJ_TIMER_DEBUG 2665 PJ_DEF(pj_status_t) pjsua_schedule_timer2_dbg( void (*cb)(void *user_data), 2666 void *user_data, 2667 unsigned msec_delay, 2668 const char *src_file, 2669 int src_line) 2670 #else 2653 2671 PJ_DEF(pj_status_t) pjsua_schedule_timer2( void (*cb)(void *user_data), 2654 2672 void *user_data, 2655 2673 unsigned msec_delay) 2674 #endif 2656 2675 { 2657 2676 pjsua_timer_list *tmr = NULL; … … 2673 2692 delay.msec = msec_delay; 2674 2693 2694 #if PJ_TIMER_DEBUG 2695 status = pjsip_endpt_schedule_timer_dbg(pjsua_var.endpt, &tmr->entry, 2696 &delay, src_file, src_line); 2697 #else 2675 2698 status = pjsip_endpt_schedule_timer(pjsua_var.endpt, &tmr->entry, &delay); 2699 #endif 2676 2700 if (status != PJ_SUCCESS) { 2677 2701 pj_list_push_back(&pjsua_var.timer_list, tmr);
Note: See TracChangeset
for help on using the changeset viewer.