diff --git a/third-party/pjproject/patches/0007-BUGBUG-Add-debug-tracing.patch b/third-party/pjproject/patches/0007-BUGBUG-Add-debug-tracing.patch new file mode 100644 index 0000000..039d438 --- /dev/null +++ b/third-party/pjproject/patches/0007-BUGBUG-Add-debug-tracing.patch @@ -0,0 +1,95 @@ +diff --git a/pjlib/src/pj/log.c b/pjlib/src/pj/log.c +index 293ad46..1d7211c 100644 +--- a/pjlib/src/pj/log.c ++++ b/pjlib/src/pj/log.c +@@ -380,7 +380,7 @@ PJ_DEF(void) pj_log( const char *sender, int level, + pre += pj_utoa_pad(ptime.msec, pre, 3, '0'); + } + if (log_decor & PJ_LOG_HAS_SENDER) { +- enum { SENDER_WIDTH = 14 }; ++ enum { SENDER_WIDTH = 23 }; + pj_size_t sender_len = strlen(sender); + if (pre!=log_buffer) *pre++ = ' '; + if (sender_len <= SENDER_WIDTH) { +diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h +index 767a025..05349da 100644 +--- a/pjsip/include/pjsip/sip_transport.h ++++ b/pjsip/include/pjsip/sip_transport.h +@@ -652,7 +652,8 @@ PJ_DECL(pj_status_t) pjsip_tx_data_create( pjsip_tpmgr *mgr, + * + * @param tdata The transmit buffer. + */ +-PJ_DECL(void) pjsip_tx_data_add_ref( pjsip_tx_data *tdata ); ++#define pjsip_tx_data_add_ref(tdata) pjsip_tx_data_add_ref_dbg(tdata, __FILE__, __LINE__, __PRETTY_FUNCTION__) ++PJ_DECL(void) pjsip_tx_data_add_ref_dbg(pjsip_tx_data *tdata, const char *file, int line, const char *func); + + /** + * Decrement reference counter of the transmit buffer. +@@ -664,7 +665,8 @@ PJ_DECL(void) pjsip_tx_data_add_ref( pjsip_tx_data *tdata ); + * status is non-zero. A status PJSIP_EBUFDESTROYED will be + * returned to inform that buffer is destroyed. + */ +-PJ_DECL(pj_status_t) pjsip_tx_data_dec_ref( pjsip_tx_data *tdata ); ++#define pjsip_tx_data_dec_ref(tdata) pjsip_tx_data_dec_ref_dbg(tdata, __FILE__, __LINE__, __PRETTY_FUNCTION__) ++PJ_DECL(pj_status_t) pjsip_tx_data_dec_ref_dbg(pjsip_tx_data *tdata, const char *file, int line, const char *func); + + /** + * Print the SIP message to transmit data buffer's internal buffer. This +diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c +index d672a6d..936dc86 100644 +--- a/pjsip/src/pjsip/sip_transport.c ++++ b/pjsip/src/pjsip/sip_transport.c +@@ -422,7 +422,8 @@ PJ_DEF(pj_status_t) pjsip_tx_data_create( pjsip_tpmgr *mgr, + tdata = PJ_POOL_ZALLOC_T(pool, pjsip_tx_data); + tdata->pool = pool; + tdata->mgr = mgr; +- pj_memcpy(tdata->obj_name, pool->obj_name, PJ_MAX_OBJ_NAME); ++ pj_ansi_snprintf(tdata->obj_name, sizeof(tdata->obj_name), "tdta%p", tdata); ++ pj_memcpy(pool->obj_name, tdata->obj_name, sizeof(pool->obj_name)); + + status = pj_atomic_create(tdata->pool, 0, &tdata->ref_cnt); + if (status != PJ_SUCCESS) { +@@ -451,6 +452,7 @@ PJ_DEF(pj_status_t) pjsip_tx_data_create( pjsip_tpmgr *mgr, + pj_atomic_inc( tdata->mgr->tdata_counter ); + #endif + ++ PJ_LOG(5,(tdata->obj_name, "Created tdata")); + *p_tdata = tdata; + return PJ_SUCCESS; + } +@@ -459,9 +461,12 @@ PJ_DEF(pj_status_t) pjsip_tx_data_create( pjsip_tpmgr *mgr, + /* + * Add reference to tx buffer. + */ +-PJ_DEF(void) pjsip_tx_data_add_ref( pjsip_tx_data *tdata ) ++PJ_DEF(void) pjsip_tx_data_add_ref_dbg(pjsip_tx_data *tdata, const char *file, int line, const char *func) + { +- pj_atomic_inc(tdata->ref_cnt); ++ pj_atomic_t *ref_cnt; ++ ++ ref_cnt = pj_atomic_inc_and_get(tdata->ref_cnt); ++ PJ_LOG(5,(tdata->obj_name, "tdata inc ref:%d %s:%s(%d)", (int) ref_cnt, file, func, line)); + } + + static void tx_data_destroy(pjsip_tx_data *tdata) +@@ -489,7 +494,7 @@ static void tx_data_destroy(pjsip_tx_data *tdata) + * Decrease transport data reference, destroy it when the reference count + * reaches zero. + */ +-PJ_DEF(pj_status_t) pjsip_tx_data_dec_ref( pjsip_tx_data *tdata ) ++PJ_DEF(pj_status_t) pjsip_tx_data_dec_ref_dbg(pjsip_tx_data *tdata, const char *file, int line, const char *func) + { + pj_atomic_value_t ref_cnt; + +@@ -498,9 +503,11 @@ PJ_DEF(pj_status_t) pjsip_tx_data_dec_ref( pjsip_tx_data *tdata ) + ref_cnt = pj_atomic_dec_and_get(tdata->ref_cnt); + pj_assert( ref_cnt >= 0); + if (ref_cnt == 0) { ++ PJ_LOG(5,(tdata->obj_name, "tdata destroy %s:%s(%d)", file, func, line)); + tx_data_destroy(tdata); + return PJSIP_EBUFDESTROYED; + } else { ++ PJ_LOG(5,(tdata->obj_name, "tdata dec ref:%d %s:%s(%d)", (int) ref_cnt, file, func, line)); + return PJ_SUCCESS; + } + }