<p>Friendly Automation <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11364">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Benjamin Keith Ford: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Revert "pjproject-bundled: Add upstream timer fixes"<br><br>This reverts commit cfeb8a59eb892e7f72b5ce0acfc0dbde1a51d3b8.<br><br>The fixes in question cause assert failures when pjproject<br>asserts are enabled. Reverting in 13 until a solution is<br>found for all branches.<br><br>Change-Id: Iae5bd340e0543613185fecb63f9c86fa985fe664<br>---<br>D third-party/pjproject/patches/0031-r2191-timer-fixes.patch<br>1 file changed, 0 insertions(+), 372 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/third-party/pjproject/patches/0031-r2191-timer-fixes.patch b/third-party/pjproject/patches/0031-r2191-timer-fixes.patch</span><br><span>deleted file mode 100644</span><br><span>index e1205f0..0000000</span><br><span>--- a/third-party/pjproject/patches/0031-r2191-timer-fixes.patch</span><br><span>+++ /dev/null</span><br><span>@@ -1,372 +0,0 @@</span><br><span style="color: hsl(0, 100%, 40%);">-From 27a076f2f6c6007c0ba41d2868a803c4d841e815 Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(0, 100%, 40%);">-From: nanang <nanang@localhost></span><br><span style="color: hsl(0, 100%, 40%);">-Date: Tue, 23 Apr 2019 08:42:45 +0000</span><br><span style="color: hsl(0, 100%, 40%);">-Subject: [PATCH] Fixed #2191: - Stricter double timer entry scheduling</span><br><span style="color: hsl(0, 100%, 40%);">- prevention. - Integrate group lock in SIP transport, e.g: for add/dec ref,</span><br><span style="color: hsl(0, 100%, 40%);">- for timer scheduling.</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>----</span><br><span style="color: hsl(0, 100%, 40%);">- pjlib/include/pj/timer.h | 2 +-</span><br><span style="color: hsl(0, 100%, 40%);">- pjlib/src/pj/timer.c | 11 +++++++-</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/include/pjsip/sip_endpoint.h | 39 +++++++++++++++++++++++++++++</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/include/pjsip/sip_transport.h | 2 ++</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/pjsip/sip_endpoint.c | 36 ++++++++++++++++++++++++++</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/pjsip/sip_transport.c | 36 +++++++++++++++++++++-----</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/pjsip/sip_transport_tcp.c | 10 +++++---</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/pjsip/sip_transport_tls.c | 14 ++++++++---</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/pjsip/sip_transport_udp.c | 2 ++</span><br><span style="color: hsl(0, 100%, 40%);">- 9 files changed, 137 insertions(+), 15 deletions(-)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjlib/include/pj/timer.h b/pjlib/include/pj/timer.h</span><br><span style="color: hsl(0, 100%, 40%);">-index df6155a81..14857b872 100644</span><br><span>---- a/pjlib/include/pj/timer.h</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjlib/include/pj/timer.h</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -252,9 +252,9 @@ PJ_DECL(pj_status_t) pj_timer_heap_schedule( pj_timer_heap_t *ht,</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * @param ht The timer heap.</span><br><span style="color: hsl(0, 100%, 40%);">- * @param entry The entry to be registered.</span><br><span style="color: hsl(0, 100%, 40%);">-+ * @param delay The interval to expire.</span><br><span style="color: hsl(0, 100%, 40%);">- * @param id_val The value to be set to the "id" field of the timer entry</span><br><span style="color: hsl(0, 100%, 40%);">- * once the timer is scheduled.</span><br><span style="color: hsl(0, 100%, 40%);">-- * @param delay The interval to expire.</span><br><span style="color: hsl(0, 100%, 40%);">- * @param grp_lock The group lock.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * @return PJ_SUCCESS, or the appropriate error code.</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjlib/src/pj/timer.c b/pjlib/src/pj/timer.c</span><br><span style="color: hsl(0, 100%, 40%);">-index f0a2cbbc9..cbdd9791f 100644</span><br><span>---- a/pjlib/src/pj/timer.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjlib/src/pj/timer.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -502,7 +502,7 @@ static pj_status_t schedule_w_grp_lock(pj_timer_heap_t *ht,</span><br><span style="color: hsl(0, 100%, 40%);">- PJ_ASSERT_RETURN(entry->cb != NULL, PJ_EINVAL);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /* Prevent same entry from being scheduled more than once */</span><br><span style="color: hsl(0, 100%, 40%);">-- PJ_ASSERT_RETURN(entry->_timer_id < 1, PJ_EINVALIDOP);</span><br><span style="color: hsl(0, 100%, 40%);">-+ //PJ_ASSERT_RETURN(entry->_timer_id < 1, PJ_EINVALIDOP);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- #if PJ_TIMER_DEBUG</span><br><span style="color: hsl(0, 100%, 40%);">- entry->src_file = src_file;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -512,6 +512,15 @@ static pj_status_t schedule_w_grp_lock(pj_timer_heap_t *ht,</span><br><span style="color: hsl(0, 100%, 40%);">- PJ_TIME_VAL_ADD(expires, *delay);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- lock_timer_heap(ht);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Prevent same entry from being scheduled more than once */</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (pj_timer_entry_running(entry)) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ unlock_timer_heap(ht);</span><br><span style="color: hsl(0, 100%, 40%);">-+ PJ_LOG(3,(THIS_FILE, "Bug! Rescheduling outstanding entry (%p)",</span><br><span style="color: hsl(0, 100%, 40%);">-+ entry));</span><br><span style="color: hsl(0, 100%, 40%);">-+ return PJ_EINVALIDOP;</span><br><span style="color: hsl(0, 100%, 40%);">-+ }</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- status = schedule_entry(ht, entry, &expires);</span><br><span style="color: hsl(0, 100%, 40%);">- if (status == PJ_SUCCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (set_id)</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/include/pjsip/sip_endpoint.h b/pjsip/include/pjsip/sip_endpoint.h</span><br><span style="color: hsl(0, 100%, 40%);">-index 99683fbe1..ee967f8d9 100644</span><br><span>---- a/pjsip/include/pjsip/sip_endpoint.h</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/include/pjsip/sip_endpoint.h</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -138,6 +138,7 @@ PJ_DECL(pj_status_t) pjsip_endpt_handle_events( pjsip_endpoint *endpt,</span><br><span style="color: hsl(0, 100%, 40%);">- PJ_DECL(pj_status_t) pjsip_endpt_handle_events2(pjsip_endpoint *endpt,</span><br><span style="color: hsl(0, 100%, 40%);">- const pj_time_val *max_timeout,</span><br><span style="color: hsl(0, 100%, 40%);">- unsigned *count);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- /**</span><br><span style="color: hsl(0, 100%, 40%);">- * Schedule timer to endpoint's timer heap. Application must poll the endpoint</span><br><span style="color: hsl(0, 100%, 40%);">- * periodically (by calling #pjsip_endpt_handle_events) to ensure that the</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -166,6 +167,44 @@ PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer( pjsip_endpoint *endpt,</span><br><span style="color: hsl(0, 100%, 40%);">- const pj_time_val *delay );</span><br><span style="color: hsl(0, 100%, 40%);">- #endif</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-+/**</span><br><span style="color: hsl(0, 100%, 40%);">-+ * Schedule timer to endpoint's timer heap with group lock. Application must</span><br><span style="color: hsl(0, 100%, 40%);">-+ * poll the endpoint periodically (by calling #pjsip_endpt_handle_events) to</span><br><span style="color: hsl(0, 100%, 40%);">-+ * ensure that the timer events are handled in timely manner. When the</span><br><span style="color: hsl(0, 100%, 40%);">-+ * timeout for the timer has elapsed, the callback specified in the entry</span><br><span style="color: hsl(0, 100%, 40%);">-+ * argument will be called. This function, like all other endpoint functions,</span><br><span style="color: hsl(0, 100%, 40%);">-+ * is thread safe.</span><br><span style="color: hsl(0, 100%, 40%);">-+ *</span><br><span style="color: hsl(0, 100%, 40%);">-+ * @param endpt The endpoint.</span><br><span style="color: hsl(0, 100%, 40%);">-+ * @param entry The timer entry.</span><br><span style="color: hsl(0, 100%, 40%);">-+ * @param delay The relative delay of the timer.</span><br><span style="color: hsl(0, 100%, 40%);">-+ * @param id_val The value to be set to the "id" field of the timer entry</span><br><span style="color: hsl(0, 100%, 40%);">-+ * once the timer is scheduled.</span><br><span style="color: hsl(0, 100%, 40%);">-+ * @param grp_lock The group lock.</span><br><span style="color: hsl(0, 100%, 40%);">-+ * @return PJ_OK (zero) if successfull.</span><br><span style="color: hsl(0, 100%, 40%);">-+ */</span><br><span style="color: hsl(0, 100%, 40%);">-+#if PJ_TIMER_DEBUG</span><br><span style="color: hsl(0, 100%, 40%);">-+#define pjsip_endpt_schedule_timer_w_grp_lock(ept,ent,d,id,gl) \</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_endpt_schedule_timer_w_grp_lock_dbg(ept,ent,d,id,gl,\</span><br><span style="color: hsl(0, 100%, 40%);">-+ __FILE__, __LINE__)</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock_dbg(</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_endpoint *endpt,</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_timer_entry *entry,</span><br><span style="color: hsl(0, 100%, 40%);">-+ const pj_time_val *delay,</span><br><span style="color: hsl(0, 100%, 40%);">-+ int id_val,</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_grp_lock_t *grp_lock,</span><br><span style="color: hsl(0, 100%, 40%);">-+ const char *src_file,</span><br><span style="color: hsl(0, 100%, 40%);">-+ int src_line);</span><br><span style="color: hsl(0, 100%, 40%);">-+#else</span><br><span style="color: hsl(0, 100%, 40%);">-+PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock(</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_endpoint *endpt,</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_timer_entry *entry,</span><br><span style="color: hsl(0, 100%, 40%);">-+ const pj_time_val *delay,</span><br><span style="color: hsl(0, 100%, 40%);">-+ int id_val,</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_grp_lock_t *grp_lock );</span><br><span style="color: hsl(0, 100%, 40%);">-+#endif</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- /**</span><br><span style="color: hsl(0, 100%, 40%);">- * Cancel the previously registered timer.</span><br><span style="color: hsl(0, 100%, 40%);">- * This function, like all other endpoint functions, is thread safe.</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h</span><br><span style="color: hsl(0, 100%, 40%);">-index addc8d521..d1ff3618b 100644</span><br><span>---- a/pjsip/include/pjsip/sip_transport.h</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/include/pjsip/sip_transport.h</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -810,6 +810,8 @@ struct pjsip_transport</span><br><span style="color: hsl(0, 100%, 40%);">- pj_pool_t *pool; /**< Pool used by transport. */</span><br><span style="color: hsl(0, 100%, 40%);">- pj_atomic_t *ref_cnt; /**< Reference counter. */</span><br><span style="color: hsl(0, 100%, 40%);">- pj_lock_t *lock; /**< Lock object. */</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_grp_lock_t *grp_lock; /**< Group lock for sync with</span><br><span style="color: hsl(0, 100%, 40%);">-+ ioqueue and timer. */</span><br><span style="color: hsl(0, 100%, 40%);">- pj_bool_t tracing; /**< Tracing enabled? */</span><br><span style="color: hsl(0, 100%, 40%);">- pj_bool_t is_shutdown; /**< Being shutdown? */</span><br><span style="color: hsl(0, 100%, 40%);">- pj_bool_t is_destroying; /**< Destroy in progress? */</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/src/pjsip/sip_endpoint.c b/pjsip/src/pjsip/sip_endpoint.c</span><br><span style="color: hsl(0, 100%, 40%);">-index d810781d5..71bc761c2 100644</span><br><span>---- a/pjsip/src/pjsip/sip_endpoint.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/src/pjsip/sip_endpoint.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -802,6 +802,42 @@ PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer( pjsip_endpoint *endpt,</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- #endif</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-+/*</span><br><span style="color: hsl(0, 100%, 40%);">-+ * Schedule timer with group lock.</span><br><span style="color: hsl(0, 100%, 40%);">-+ */</span><br><span style="color: hsl(0, 100%, 40%);">-+#if PJ_TIMER_DEBUG</span><br><span style="color: hsl(0, 100%, 40%);">-+PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock_dbg(</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_endpoint *endpt,</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_timer_entry *entry,</span><br><span style="color: hsl(0, 100%, 40%);">-+ const pj_time_val *delay,</span><br><span style="color: hsl(0, 100%, 40%);">-+ int id_val,</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_grp_lock_t *grp_lock,</span><br><span style="color: hsl(0, 100%, 40%);">-+ const char *src_file,</span><br><span style="color: hsl(0, 100%, 40%);">-+ int src_line)</span><br><span style="color: hsl(0, 100%, 40%);">-+{</span><br><span style="color: hsl(0, 100%, 40%);">-+ PJ_LOG(6, (THIS_FILE, "pjsip_endpt_schedule_timer_w_grp_lock"</span><br><span style="color: hsl(0, 100%, 40%);">-+ "(entry=%p, delay=%u.%u, grp_lock=%p)",</span><br><span style="color: hsl(0, 100%, 40%);">-+ entry, delay->sec, delay->msec, grp_lock));</span><br><span style="color: hsl(0, 100%, 40%);">-+ return pj_timer_heap_schedule_w_grp_lock_dbg(endpt->timer_heap, entry,</span><br><span style="color: hsl(0, 100%, 40%);">-+ delay, id_val, grp_lock,</span><br><span style="color: hsl(0, 100%, 40%);">-+ src_file, src_line);</span><br><span style="color: hsl(0, 100%, 40%);">-+}</span><br><span style="color: hsl(0, 100%, 40%);">-+#else</span><br><span style="color: hsl(0, 100%, 40%);">-+PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock(</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_endpoint *endpt,</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_timer_entry *entry,</span><br><span style="color: hsl(0, 100%, 40%);">-+ const pj_time_val *delay,</span><br><span style="color: hsl(0, 100%, 40%);">-+ int id_val,</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_grp_lock_t *grp_lock )</span><br><span style="color: hsl(0, 100%, 40%);">-+{</span><br><span style="color: hsl(0, 100%, 40%);">-+ PJ_LOG(6, (THIS_FILE, "pjsip_endpt_schedule_timer_w_grp_lock"</span><br><span style="color: hsl(0, 100%, 40%);">-+ "(entry=%p, delay=%u.%u, grp_lock=%p)",</span><br><span style="color: hsl(0, 100%, 40%);">-+ entry, delay->sec, delay->msec, grp_lock));</span><br><span style="color: hsl(0, 100%, 40%);">-+ return pj_timer_heap_schedule_w_grp_lock( endpt->timer_heap, entry,</span><br><span style="color: hsl(0, 100%, 40%);">-+ delay, id_val, grp_lock );</span><br><span style="color: hsl(0, 100%, 40%);">-+}</span><br><span style="color: hsl(0, 100%, 40%);">-+#endif</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- /*</span><br><span style="color: hsl(0, 100%, 40%);">- * Cancel the previously registered timer.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c</span><br><span style="color: hsl(0, 100%, 40%);">-index 67e235a39..529604399 100644</span><br><span>---- a/pjsip/src/pjsip/sip_transport.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/src/pjsip/sip_transport.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1012,6 +1012,9 @@ static void transport_idle_callback(pj_timer_heap_t *timer_heap,</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- PJ_UNUSED_ARG(timer_heap);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-+ if (entry->id == PJ_FALSE)</span><br><span style="color: hsl(0, 100%, 40%);">-+ return;</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- entry->id = PJ_FALSE;</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_transport_destroy(tp);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1049,6 +1052,10 @@ PJ_DEF(pj_status_t) pjsip_transport_add_ref( pjsip_transport *tp )</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- PJ_ASSERT_RETURN(tp != NULL, PJ_EINVAL);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Add ref transport group lock, if any */</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (tp->grp_lock)</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_grp_lock_add_ref(tp->grp_lock);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- /* Cache some vars for checking transport validity later */</span><br><span style="color: hsl(0, 100%, 40%);">- tpmgr = tp->tpmgr;</span><br><span style="color: hsl(0, 100%, 40%);">- key_len = sizeof(tp->key.type) + tp->addr_len;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1063,8 +1070,8 @@ PJ_DEF(pj_status_t) pjsip_transport_add_ref( pjsip_transport *tp )</span><br><span style="color: hsl(0, 100%, 40%);">- pj_atomic_get(tp->ref_cnt) == 1)</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">- if (tp->idle_timer.id != PJ_FALSE) {</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_endpt_cancel_timer(tp->tpmgr->endpt, &tp->idle_timer);</span><br><span style="color: hsl(0, 100%, 40%);">- tp->idle_timer.id = PJ_FALSE;</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_endpt_cancel_timer(tp->tpmgr->endpt, &tp->idle_timer);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- pj_lock_release(tpmgr->lock);</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1114,14 +1121,23 @@ PJ_DEF(pj_status_t) pjsip_transport_dec_ref( pjsip_transport *tp )</span><br><span style="color: hsl(0, 100%, 40%);">- delay.msec = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- pj_assert(tp->idle_timer.id == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-- tp->idle_timer.id = PJ_TRUE;</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_endpt_schedule_timer(tp->tpmgr->endpt, &tp->idle_timer, </span><br><span style="color: hsl(0, 100%, 40%);">-- &delay);</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Avoid double timer entry scheduling */</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (pj_timer_entry_running(&tp->idle_timer))</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_endpt_cancel_timer(tp->tpmgr->endpt, &tp->idle_timer);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_endpt_schedule_timer_w_grp_lock(tp->tpmgr->endpt,</span><br><span style="color: hsl(0, 100%, 40%);">-+ &tp->idle_timer,</span><br><span style="color: hsl(0, 100%, 40%);">-+ &delay,</span><br><span style="color: hsl(0, 100%, 40%);">-+ PJ_TRUE,</span><br><span style="color: hsl(0, 100%, 40%);">-+ tp->grp_lock);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- pj_lock_release(tpmgr->lock);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Dec ref transport group lock, if any */</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (tp->grp_lock)</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_grp_lock_dec_ref(tp->grp_lock);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- return PJ_SUCCESS;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1168,6 +1184,10 @@ PJ_DEF(pj_status_t) pjsip_transport_register( pjsip_tpmgr *mgr,</span><br><span style="color: hsl(0, 100%, 40%);">- /* Register new entry */</span><br><span style="color: hsl(0, 100%, 40%);">- pj_hash_set(tp->pool, mgr->table, &tp->key, key_len, hval, tp);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Add ref transport group lock, if any */</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (tp->grp_lock)</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_grp_lock_add_ref(tp->grp_lock);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- pj_lock_release(mgr->lock);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- TRACE_((THIS_FILE,"Transport %s registered: type=%s, remote=%s:%d",</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1199,8 +1219,8 @@ static pj_status_t destroy_transport( pjsip_tpmgr *mgr,</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- //pj_assert(tp->idle_timer.id == PJ_FALSE);</span><br><span style="color: hsl(0, 100%, 40%);">- if (tp->idle_timer.id != PJ_FALSE) {</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_endpt_cancel_timer(mgr->endpt, &tp->idle_timer);</span><br><span style="color: hsl(0, 100%, 40%);">- tp->idle_timer.id = PJ_FALSE;</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_endpt_cancel_timer(mgr->endpt, &tp->idle_timer);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /*</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1226,6 +1246,10 @@ static pj_status_t destroy_transport( pjsip_tpmgr *mgr,</span><br><span style="color: hsl(0, 100%, 40%);">- pj_lock_release(mgr->lock);</span><br><span style="color: hsl(0, 100%, 40%);">- pj_lock_release(tp->lock);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Dec ref transport group lock, if any */</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (tp->grp_lock)</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_grp_lock_dec_ref(tp->grp_lock);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- /* Destroy. */</span><br><span style="color: hsl(0, 100%, 40%);">- return tp->destroy(tp);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/src/pjsip/sip_transport_tcp.c b/pjsip/src/pjsip/sip_transport_tcp.c</span><br><span style="color: hsl(0, 100%, 40%);">-index fe327459e..374bf461b 100644</span><br><span>---- a/pjsip/src/pjsip/sip_transport_tcp.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/src/pjsip/sip_transport_tcp.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -692,6 +692,8 @@ static pj_status_t tcp_create( struct tcp_listener *listener,</span><br><span style="color: hsl(0, 100%, 40%);">- pj_grp_lock_add_ref(tcp->grp_lock);</span><br><span style="color: hsl(0, 100%, 40%);">- pj_grp_lock_add_handler(tcp->grp_lock, pool, tcp, &tcp_on_destroy);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-+ tcp->base.grp_lock = tcp->grp_lock;</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- /* Create active socket */</span><br><span style="color: hsl(0, 100%, 40%);">- pj_activesock_cfg_default(&asock_cfg);</span><br><span style="color: hsl(0, 100%, 40%);">- asock_cfg.async_cnt = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -746,7 +748,11 @@ static pj_status_t tcp_create( struct tcp_listener *listener,</span><br><span style="color: hsl(0, 100%, 40%);">- return PJ_SUCCESS;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- on_error:</span><br><span style="color: hsl(0, 100%, 40%);">-- tcp_destroy(&tcp->base, status);</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (tcp->grp_lock && pj_grp_lock_get_ref(tcp->grp_lock))</span><br><span style="color: hsl(0, 100%, 40%);">-+ tcp_destroy(&tcp->base, status);</span><br><span style="color: hsl(0, 100%, 40%);">-+ else</span><br><span style="color: hsl(0, 100%, 40%);">-+ tcp_on_destroy(tcp);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- return status;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-@@ -867,8 +873,6 @@ static pj_status_t tcp_destroy(pjsip_transport *transport,</span><br><span style="color: hsl(0, 100%, 40%);">- tcp->grp_lock = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_grp_lock_dec_ref(grp_lock);</span><br><span style="color: hsl(0, 100%, 40%);">- /* Transport may have been deleted at this point */</span><br><span style="color: hsl(0, 100%, 40%);">-- } else {</span><br><span style="color: hsl(0, 100%, 40%);">-- tcp_on_destroy(tcp);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- return PJ_SUCCESS;</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/src/pjsip/sip_transport_tls.c b/pjsip/src/pjsip/sip_transport_tls.c</span><br><span style="color: hsl(0, 100%, 40%);">-index d3afae5e9..dd3a4d639 100644</span><br><span>---- a/pjsip/src/pjsip/sip_transport_tls.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/src/pjsip/sip_transport_tls.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -165,6 +165,10 @@ static pj_status_t tls_create(struct tls_listener *listener,</span><br><span style="color: hsl(0, 100%, 40%);">- struct tls_transport **p_tls);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-+/* Clean up TLS resources */</span><br><span style="color: hsl(0, 100%, 40%);">-+static void tls_on_destroy(void *arg);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- static void tls_perror(const char *sender, const char *title,</span><br><span style="color: hsl(0, 100%, 40%);">- pj_status_t status)</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -893,7 +897,11 @@ static pj_status_t tls_create( struct tls_listener *listener,</span><br><span style="color: hsl(0, 100%, 40%);">- return PJ_SUCCESS;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- on_error:</span><br><span style="color: hsl(0, 100%, 40%);">-- tls_destroy(&tls->base, status);</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (tls->grp_lock && pj_grp_lock_get_ref(tls->grp_lock))</span><br><span style="color: hsl(0, 100%, 40%);">-+ tls_destroy(&tls->base, status);</span><br><span style="color: hsl(0, 100%, 40%);">-+ else</span><br><span style="color: hsl(0, 100%, 40%);">-+ tls_on_destroy(tls);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- return status;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1048,8 +1056,6 @@ static pj_status_t tls_destroy(pjsip_transport *transport,</span><br><span style="color: hsl(0, 100%, 40%);">- tls->grp_lock = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_grp_lock_dec_ref(grp_lock);</span><br><span style="color: hsl(0, 100%, 40%);">- /* Transport may have been deleted at this point */</span><br><span style="color: hsl(0, 100%, 40%);">-- } else {</span><br><span style="color: hsl(0, 100%, 40%);">-- tls_on_destroy(tls);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- return PJ_SUCCESS;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1235,7 +1241,7 @@ static pj_status_t lis_create_transport(pjsip_tpfactory *factory,</span><br><span style="color: hsl(0, 100%, 40%);">- pj_ssl_sock_set_user_data(tls->ssock, tls);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /* Set up the group lock */</span><br><span style="color: hsl(0, 100%, 40%);">-- tls->grp_lock = glock;</span><br><span style="color: hsl(0, 100%, 40%);">-+ tls->grp_lock = tls->base.grp_lock = glock;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_grp_lock_add_ref(tls->grp_lock);</span><br><span style="color: hsl(0, 100%, 40%);">- pj_grp_lock_add_handler(tls->grp_lock, pool, tls, &tls_on_destroy);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/src/pjsip/sip_transport_udp.c b/pjsip/src/pjsip/sip_transport_udp.c</span><br><span style="color: hsl(0, 100%, 40%);">-index dbda474cf..b82d519c9 100644</span><br><span>---- a/pjsip/src/pjsip/sip_transport_udp.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/src/pjsip/sip_transport_udp.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -691,6 +691,8 @@ static pj_status_t register_to_ioqueue(struct udp_transport *tp)</span><br><span style="color: hsl(0, 100%, 40%);">- pj_grp_lock_add_ref(tp->grp_lock);</span><br><span style="color: hsl(0, 100%, 40%);">- pj_grp_lock_add_handler(tp->grp_lock, tp->base.pool, tp,</span><br><span style="color: hsl(0, 100%, 40%);">- &udp_on_destroy);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ tp->base.grp_lock = tp->grp_lock;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /* Register to ioqueue. */</span><br><span>--- </span><br><span style="color: hsl(0, 100%, 40%);">-2.20.1</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11364">change 11364</a>. To unsubscribe, or for help writing mail filters, 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/c/asterisk/+/11364"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: Iae5bd340e0543613185fecb63f9c86fa985fe664 </div>
<div style="display:none"> Gerrit-Change-Number: 11364 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>