<p>Joshua Colp has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11391">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjproject-bundled: Add upstream timer fixes<br><br>Fixed #2191:<br> - Stricter double timer entry scheduling prevention.<br> - Integrate group lock in SIP transport, e.g: for add/dec ref,<br> for timer scheduling.<br><br>ASTERISK-28161<br>Reported-by: Ross Beer<br><br>Change-Id: I2e09aa66de0dda9414d8a8259a649c4d2d96a9f5<br>---<br>A third-party/pjproject/patches/0031-Re-2191-transport-timer-cleanup.patch<br>A third-party/pjproject/patches/0032-Re-2191-Fixed-crash-in-SIP-transport-destroy-due-to-.patch<br>2 files changed, 513 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/91/11391/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/third-party/pjproject/patches/0031-Re-2191-transport-timer-cleanup.patch b/third-party/pjproject/patches/0031-Re-2191-transport-timer-cleanup.patch</span><br><span>new file mode 100644</span><br><span>index 0000000..e1205f0</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/pjproject/patches/0031-Re-2191-transport-timer-cleanup.patch</span><br><span>@@ -0,0 +1,372 @@</span><br><span style="color: hsl(120, 100%, 40%);">+From 27a076f2f6c6007c0ba41d2868a803c4d841e815 Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(120, 100%, 40%);">+From: nanang <nanang@localhost></span><br><span style="color: hsl(120, 100%, 40%);">+Date: Tue, 23 Apr 2019 08:42:45 +0000</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: [PATCH] Fixed #2191: - Stricter double timer entry scheduling</span><br><span style="color: hsl(120, 100%, 40%);">+ prevention. - Integrate group lock in SIP transport, e.g: for add/dec ref,</span><br><span style="color: hsl(120, 100%, 40%);">+ for timer scheduling.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+---</span><br><span style="color: hsl(120, 100%, 40%);">+ pjlib/include/pj/timer.h | 2 +-</span><br><span style="color: hsl(120, 100%, 40%);">+ pjlib/src/pj/timer.c | 11 +++++++-</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip/include/pjsip/sip_endpoint.h | 39 +++++++++++++++++++++++++++++</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip/include/pjsip/sip_transport.h | 2 ++</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip/src/pjsip/sip_endpoint.c | 36 ++++++++++++++++++++++++++</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip/src/pjsip/sip_transport.c | 36 +++++++++++++++++++++-----</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip/src/pjsip/sip_transport_tcp.c | 10 +++++---</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip/src/pjsip/sip_transport_tls.c | 14 ++++++++---</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip/src/pjsip/sip_transport_udp.c | 2 ++</span><br><span style="color: hsl(120, 100%, 40%);">+ 9 files changed, 137 insertions(+), 15 deletions(-)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjlib/include/pj/timer.h b/pjlib/include/pj/timer.h</span><br><span style="color: hsl(120, 100%, 40%);">+index df6155a81..14857b872 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjlib/include/pj/timer.h</span><br><span>++++ b/pjlib/include/pj/timer.h</span><br><span style="color: hsl(120, 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(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * @param ht The timer heap.</span><br><span style="color: hsl(120, 100%, 40%);">+ * @param entry The entry to be registered.</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param delay The interval to expire.</span><br><span style="color: hsl(120, 100%, 40%);">+ * @param id_val The value to be set to the "id" field of the timer entry</span><br><span style="color: hsl(120, 100%, 40%);">+ * once the timer is scheduled.</span><br><span style="color: hsl(120, 100%, 40%);">+- * @param delay The interval to expire.</span><br><span style="color: hsl(120, 100%, 40%);">+ * @param grp_lock The group lock.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * @return PJ_SUCCESS, or the appropriate error code.</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjlib/src/pj/timer.c b/pjlib/src/pj/timer.c</span><br><span style="color: hsl(120, 100%, 40%);">+index f0a2cbbc9..cbdd9791f 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjlib/src/pj/timer.c</span><br><span>++++ b/pjlib/src/pj/timer.c</span><br><span style="color: hsl(120, 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(120, 100%, 40%);">+ PJ_ASSERT_RETURN(entry->cb != NULL, PJ_EINVAL);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Prevent same entry from being scheduled more than once */</span><br><span style="color: hsl(120, 100%, 40%);">+- PJ_ASSERT_RETURN(entry->_timer_id < 1, PJ_EINVALIDOP);</span><br><span style="color: hsl(120, 100%, 40%);">++ //PJ_ASSERT_RETURN(entry->_timer_id < 1, PJ_EINVALIDOP);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ #if PJ_TIMER_DEBUG</span><br><span style="color: hsl(120, 100%, 40%);">+ entry->src_file = src_file;</span><br><span style="color: hsl(120, 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(120, 100%, 40%);">+ PJ_TIME_VAL_ADD(expires, *delay);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ lock_timer_heap(ht);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ /* Prevent same entry from being scheduled more than once */</span><br><span style="color: hsl(120, 100%, 40%);">++ if (pj_timer_entry_running(entry)) {</span><br><span style="color: hsl(120, 100%, 40%);">++ unlock_timer_heap(ht);</span><br><span style="color: hsl(120, 100%, 40%);">++ PJ_LOG(3,(THIS_FILE, "Bug! Rescheduling outstanding entry (%p)",</span><br><span style="color: hsl(120, 100%, 40%);">++ entry));</span><br><span style="color: hsl(120, 100%, 40%);">++ return PJ_EINVALIDOP;</span><br><span style="color: hsl(120, 100%, 40%);">++ }</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ status = schedule_entry(ht, entry, &expires);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (status == PJ_SUCCESS) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (set_id)</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjsip/include/pjsip/sip_endpoint.h b/pjsip/include/pjsip/sip_endpoint.h</span><br><span style="color: hsl(120, 100%, 40%);">+index 99683fbe1..ee967f8d9 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjsip/include/pjsip/sip_endpoint.h</span><br><span>++++ b/pjsip/include/pjsip/sip_endpoint.h</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -138,6 +138,7 @@ PJ_DECL(pj_status_t) pjsip_endpt_handle_events( pjsip_endpoint *endpt,</span><br><span style="color: hsl(120, 100%, 40%);">+ PJ_DECL(pj_status_t) pjsip_endpt_handle_events2(pjsip_endpoint *endpt,</span><br><span style="color: hsl(120, 100%, 40%);">+ const pj_time_val *max_timeout,</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned *count);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ /**</span><br><span style="color: hsl(120, 100%, 40%);">+ * Schedule timer to endpoint's timer heap. Application must poll the endpoint</span><br><span style="color: hsl(120, 100%, 40%);">+ * periodically (by calling #pjsip_endpt_handle_events) to ensure that the</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -166,6 +167,44 @@ PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer( pjsip_endpoint *endpt,</span><br><span style="color: hsl(120, 100%, 40%);">+ const pj_time_val *delay );</span><br><span style="color: hsl(120, 100%, 40%);">+ #endif</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++/**</span><br><span style="color: hsl(120, 100%, 40%);">++ * Schedule timer to endpoint's timer heap with group lock. Application must</span><br><span style="color: hsl(120, 100%, 40%);">++ * poll the endpoint periodically (by calling #pjsip_endpt_handle_events) to</span><br><span style="color: hsl(120, 100%, 40%);">++ * ensure that the timer events are handled in timely manner. When the</span><br><span style="color: hsl(120, 100%, 40%);">++ * timeout for the timer has elapsed, the callback specified in the entry</span><br><span style="color: hsl(120, 100%, 40%);">++ * argument will be called. This function, like all other endpoint functions,</span><br><span style="color: hsl(120, 100%, 40%);">++ * is thread safe.</span><br><span style="color: hsl(120, 100%, 40%);">++ *</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param endpt The endpoint.</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param entry The timer entry.</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param delay The relative delay of the timer.</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param id_val The value to be set to the "id" field of the timer entry</span><br><span style="color: hsl(120, 100%, 40%);">++ * once the timer is scheduled.</span><br><span style="color: hsl(120, 100%, 40%);">++ * @param grp_lock The group lock.</span><br><span style="color: hsl(120, 100%, 40%);">++ * @return PJ_OK (zero) if successfull.</span><br><span style="color: hsl(120, 100%, 40%);">++ */</span><br><span style="color: hsl(120, 100%, 40%);">++#if PJ_TIMER_DEBUG</span><br><span style="color: hsl(120, 100%, 40%);">++#define pjsip_endpt_schedule_timer_w_grp_lock(ept,ent,d,id,gl) \</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_endpt_schedule_timer_w_grp_lock_dbg(ept,ent,d,id,gl,\</span><br><span style="color: hsl(120, 100%, 40%);">++ __FILE__, __LINE__)</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock_dbg(</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_endpoint *endpt,</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_timer_entry *entry,</span><br><span style="color: hsl(120, 100%, 40%);">++ const pj_time_val *delay,</span><br><span style="color: hsl(120, 100%, 40%);">++ int id_val,</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_grp_lock_t *grp_lock,</span><br><span style="color: hsl(120, 100%, 40%);">++ const char *src_file,</span><br><span style="color: hsl(120, 100%, 40%);">++ int src_line);</span><br><span style="color: hsl(120, 100%, 40%);">++#else</span><br><span style="color: hsl(120, 100%, 40%);">++PJ_DECL(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock(</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_endpoint *endpt,</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_timer_entry *entry,</span><br><span style="color: hsl(120, 100%, 40%);">++ const pj_time_val *delay,</span><br><span style="color: hsl(120, 100%, 40%);">++ int id_val,</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_grp_lock_t *grp_lock );</span><br><span style="color: hsl(120, 100%, 40%);">++#endif</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ /**</span><br><span style="color: hsl(120, 100%, 40%);">+ * Cancel the previously registered timer.</span><br><span style="color: hsl(120, 100%, 40%);">+ * This function, like all other endpoint functions, is thread safe.</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h</span><br><span style="color: hsl(120, 100%, 40%);">+index addc8d521..d1ff3618b 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjsip/include/pjsip/sip_transport.h</span><br><span>++++ b/pjsip/include/pjsip/sip_transport.h</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -810,6 +810,8 @@ struct pjsip_transport</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_pool_t *pool; /**< Pool used by transport. */</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_atomic_t *ref_cnt; /**< Reference counter. */</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_lock_t *lock; /**< Lock object. */</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_grp_lock_t *grp_lock; /**< Group lock for sync with</span><br><span style="color: hsl(120, 100%, 40%);">++ ioqueue and timer. */</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_bool_t tracing; /**< Tracing enabled? */</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_bool_t is_shutdown; /**< Being shutdown? */</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_bool_t is_destroying; /**< Destroy in progress? */</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjsip/src/pjsip/sip_endpoint.c b/pjsip/src/pjsip/sip_endpoint.c</span><br><span style="color: hsl(120, 100%, 40%);">+index d810781d5..71bc761c2 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjsip/src/pjsip/sip_endpoint.c</span><br><span>++++ b/pjsip/src/pjsip/sip_endpoint.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -802,6 +802,42 @@ PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer( pjsip_endpoint *endpt,</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ #endif</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++/*</span><br><span style="color: hsl(120, 100%, 40%);">++ * Schedule timer with group lock.</span><br><span style="color: hsl(120, 100%, 40%);">++ */</span><br><span style="color: hsl(120, 100%, 40%);">++#if PJ_TIMER_DEBUG</span><br><span style="color: hsl(120, 100%, 40%);">++PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock_dbg(</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_endpoint *endpt,</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_timer_entry *entry,</span><br><span style="color: hsl(120, 100%, 40%);">++ const pj_time_val *delay,</span><br><span style="color: hsl(120, 100%, 40%);">++ int id_val,</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_grp_lock_t *grp_lock,</span><br><span style="color: hsl(120, 100%, 40%);">++ const char *src_file,</span><br><span style="color: hsl(120, 100%, 40%);">++ int src_line)</span><br><span style="color: hsl(120, 100%, 40%);">++{</span><br><span style="color: hsl(120, 100%, 40%);">++ PJ_LOG(6, (THIS_FILE, "pjsip_endpt_schedule_timer_w_grp_lock"</span><br><span style="color: hsl(120, 100%, 40%);">++ "(entry=%p, delay=%u.%u, grp_lock=%p)",</span><br><span style="color: hsl(120, 100%, 40%);">++ entry, delay->sec, delay->msec, grp_lock));</span><br><span style="color: hsl(120, 100%, 40%);">++ return pj_timer_heap_schedule_w_grp_lock_dbg(endpt->timer_heap, entry,</span><br><span style="color: hsl(120, 100%, 40%);">++ delay, id_val, grp_lock,</span><br><span style="color: hsl(120, 100%, 40%);">++ src_file, src_line);</span><br><span style="color: hsl(120, 100%, 40%);">++}</span><br><span style="color: hsl(120, 100%, 40%);">++#else</span><br><span style="color: hsl(120, 100%, 40%);">++PJ_DEF(pj_status_t) pjsip_endpt_schedule_timer_w_grp_lock(</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_endpoint *endpt,</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_timer_entry *entry,</span><br><span style="color: hsl(120, 100%, 40%);">++ const pj_time_val *delay,</span><br><span style="color: hsl(120, 100%, 40%);">++ int id_val,</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_grp_lock_t *grp_lock )</span><br><span style="color: hsl(120, 100%, 40%);">++{</span><br><span style="color: hsl(120, 100%, 40%);">++ PJ_LOG(6, (THIS_FILE, "pjsip_endpt_schedule_timer_w_grp_lock"</span><br><span style="color: hsl(120, 100%, 40%);">++ "(entry=%p, delay=%u.%u, grp_lock=%p)",</span><br><span style="color: hsl(120, 100%, 40%);">++ entry, delay->sec, delay->msec, grp_lock));</span><br><span style="color: hsl(120, 100%, 40%);">++ return pj_timer_heap_schedule_w_grp_lock( endpt->timer_heap, entry,</span><br><span style="color: hsl(120, 100%, 40%);">++ delay, id_val, grp_lock );</span><br><span style="color: hsl(120, 100%, 40%);">++}</span><br><span style="color: hsl(120, 100%, 40%);">++#endif</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Cancel the previously registered timer.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c</span><br><span style="color: hsl(120, 100%, 40%);">+index 67e235a39..529604399 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjsip/src/pjsip/sip_transport.c</span><br><span>++++ b/pjsip/src/pjsip/sip_transport.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1012,6 +1012,9 @@ static void transport_idle_callback(pj_timer_heap_t *timer_heap,</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ PJ_UNUSED_ARG(timer_heap);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++ if (entry->id == PJ_FALSE)</span><br><span style="color: hsl(120, 100%, 40%);">++ return;</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ entry->id = PJ_FALSE;</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_transport_destroy(tp);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1049,6 +1052,10 @@ PJ_DEF(pj_status_t) pjsip_transport_add_ref( pjsip_transport *tp )</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ PJ_ASSERT_RETURN(tp != NULL, PJ_EINVAL);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++ /* Add ref transport group lock, if any */</span><br><span style="color: hsl(120, 100%, 40%);">++ if (tp->grp_lock)</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_grp_lock_add_ref(tp->grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Cache some vars for checking transport validity later */</span><br><span style="color: hsl(120, 100%, 40%);">+ tpmgr = tp->tpmgr;</span><br><span style="color: hsl(120, 100%, 40%);">+ key_len = sizeof(tp->key.type) + tp->addr_len;</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1063,8 +1070,8 @@ PJ_DEF(pj_status_t) pjsip_transport_add_ref( pjsip_transport *tp )</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_atomic_get(tp->ref_cnt) == 1)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (tp->idle_timer.id != PJ_FALSE) {</span><br><span style="color: hsl(120, 100%, 40%);">+- pjsip_endpt_cancel_timer(tp->tpmgr->endpt, &tp->idle_timer);</span><br><span style="color: hsl(120, 100%, 40%);">+ tp->idle_timer.id = PJ_FALSE;</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_endpt_cancel_timer(tp->tpmgr->endpt, &tp->idle_timer);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_lock_release(tpmgr->lock);</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1114,14 +1121,23 @@ PJ_DEF(pj_status_t) pjsip_transport_dec_ref( pjsip_transport *tp )</span><br><span style="color: hsl(120, 100%, 40%);">+ delay.msec = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- pj_assert(tp->idle_timer.id == 0);</span><br><span style="color: hsl(120, 100%, 40%);">+- tp->idle_timer.id = PJ_TRUE;</span><br><span style="color: hsl(120, 100%, 40%);">+- pjsip_endpt_schedule_timer(tp->tpmgr->endpt, &tp->idle_timer, </span><br><span style="color: hsl(120, 100%, 40%);">+- &delay);</span><br><span style="color: hsl(120, 100%, 40%);">++ /* Avoid double timer entry scheduling */</span><br><span style="color: hsl(120, 100%, 40%);">++ if (pj_timer_entry_running(&tp->idle_timer))</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_endpt_cancel_timer(tp->tpmgr->endpt, &tp->idle_timer);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_endpt_schedule_timer_w_grp_lock(tp->tpmgr->endpt,</span><br><span style="color: hsl(120, 100%, 40%);">++ &tp->idle_timer,</span><br><span style="color: hsl(120, 100%, 40%);">++ &delay,</span><br><span style="color: hsl(120, 100%, 40%);">++ PJ_TRUE,</span><br><span style="color: hsl(120, 100%, 40%);">++ tp->grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_lock_release(tpmgr->lock);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++ /* Dec ref transport group lock, if any */</span><br><span style="color: hsl(120, 100%, 40%);">++ if (tp->grp_lock)</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_grp_lock_dec_ref(tp->grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ return PJ_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1168,6 +1184,10 @@ PJ_DEF(pj_status_t) pjsip_transport_register( pjsip_tpmgr *mgr,</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Register new entry */</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_hash_set(tp->pool, mgr->table, &tp->key, key_len, hval, tp);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++ /* Add ref transport group lock, if any */</span><br><span style="color: hsl(120, 100%, 40%);">++ if (tp->grp_lock)</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_grp_lock_add_ref(tp->grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_lock_release(mgr->lock);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ TRACE_((THIS_FILE,"Transport %s registered: type=%s, remote=%s:%d",</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1199,8 +1219,8 @@ static pj_status_t destroy_transport( pjsip_tpmgr *mgr,</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ //pj_assert(tp->idle_timer.id == PJ_FALSE);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (tp->idle_timer.id != PJ_FALSE) {</span><br><span style="color: hsl(120, 100%, 40%);">+- pjsip_endpt_cancel_timer(mgr->endpt, &tp->idle_timer);</span><br><span style="color: hsl(120, 100%, 40%);">+ tp->idle_timer.id = PJ_FALSE;</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_endpt_cancel_timer(mgr->endpt, &tp->idle_timer);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1226,6 +1246,10 @@ static pj_status_t destroy_transport( pjsip_tpmgr *mgr,</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_lock_release(mgr->lock);</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_lock_release(tp->lock);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++ /* Dec ref transport group lock, if any */</span><br><span style="color: hsl(120, 100%, 40%);">++ if (tp->grp_lock)</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_grp_lock_dec_ref(tp->grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Destroy. */</span><br><span style="color: hsl(120, 100%, 40%);">+ return tp->destroy(tp);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 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(120, 100%, 40%);">+index fe327459e..374bf461b 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjsip/src/pjsip/sip_transport_tcp.c</span><br><span>++++ b/pjsip/src/pjsip/sip_transport_tcp.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -692,6 +692,8 @@ static pj_status_t tcp_create( struct tcp_listener *listener,</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_grp_lock_add_ref(tcp->grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_grp_lock_add_handler(tcp->grp_lock, pool, tcp, &tcp_on_destroy);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++ tcp->base.grp_lock = tcp->grp_lock;</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Create active socket */</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_activesock_cfg_default(&asock_cfg);</span><br><span style="color: hsl(120, 100%, 40%);">+ asock_cfg.async_cnt = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -746,7 +748,11 @@ static pj_status_t tcp_create( struct tcp_listener *listener,</span><br><span style="color: hsl(120, 100%, 40%);">+ return PJ_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ on_error:</span><br><span style="color: hsl(120, 100%, 40%);">+- tcp_destroy(&tcp->base, status);</span><br><span style="color: hsl(120, 100%, 40%);">++ if (tcp->grp_lock && pj_grp_lock_get_ref(tcp->grp_lock))</span><br><span style="color: hsl(120, 100%, 40%);">++ tcp_destroy(&tcp->base, status);</span><br><span style="color: hsl(120, 100%, 40%);">++ else</span><br><span style="color: hsl(120, 100%, 40%);">++ tcp_on_destroy(tcp);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ return status;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -867,8 +873,6 @@ static pj_status_t tcp_destroy(pjsip_transport *transport,</span><br><span style="color: hsl(120, 100%, 40%);">+ tcp->grp_lock = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_grp_lock_dec_ref(grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Transport may have been deleted at this point */</span><br><span style="color: hsl(120, 100%, 40%);">+- } else {</span><br><span style="color: hsl(120, 100%, 40%);">+- tcp_on_destroy(tcp);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ return PJ_SUCCESS;</span><br><span style="color: hsl(120, 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(120, 100%, 40%);">+index d3afae5e9..dd3a4d639 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjsip/src/pjsip/sip_transport_tls.c</span><br><span>++++ b/pjsip/src/pjsip/sip_transport_tls.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -165,6 +165,10 @@ static pj_status_t tls_create(struct tls_listener *listener,</span><br><span style="color: hsl(120, 100%, 40%);">+ struct tls_transport **p_tls);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++/* Clean up TLS resources */</span><br><span style="color: hsl(120, 100%, 40%);">++static void tls_on_destroy(void *arg);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ static void tls_perror(const char *sender, const char *title,</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_status_t status)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -893,7 +897,11 @@ static pj_status_t tls_create( struct tls_listener *listener,</span><br><span style="color: hsl(120, 100%, 40%);">+ return PJ_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ on_error:</span><br><span style="color: hsl(120, 100%, 40%);">+- tls_destroy(&tls->base, status);</span><br><span style="color: hsl(120, 100%, 40%);">++ if (tls->grp_lock && pj_grp_lock_get_ref(tls->grp_lock))</span><br><span style="color: hsl(120, 100%, 40%);">++ tls_destroy(&tls->base, status);</span><br><span style="color: hsl(120, 100%, 40%);">++ else</span><br><span style="color: hsl(120, 100%, 40%);">++ tls_on_destroy(tls);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ return status;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1048,8 +1056,6 @@ static pj_status_t tls_destroy(pjsip_transport *transport,</span><br><span style="color: hsl(120, 100%, 40%);">+ tls->grp_lock = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_grp_lock_dec_ref(grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Transport may have been deleted at this point */</span><br><span style="color: hsl(120, 100%, 40%);">+- } else {</span><br><span style="color: hsl(120, 100%, 40%);">+- tls_on_destroy(tls);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ return PJ_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1235,7 +1241,7 @@ static pj_status_t lis_create_transport(pjsip_tpfactory *factory,</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_ssl_sock_set_user_data(tls->ssock, tls);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Set up the group lock */</span><br><span style="color: hsl(120, 100%, 40%);">+- tls->grp_lock = glock;</span><br><span style="color: hsl(120, 100%, 40%);">++ tls->grp_lock = tls->base.grp_lock = glock;</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_grp_lock_add_ref(tls->grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_grp_lock_add_handler(tls->grp_lock, pool, tls, &tls_on_destroy);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 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(120, 100%, 40%);">+index dbda474cf..b82d519c9 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjsip/src/pjsip/sip_transport_udp.c</span><br><span>++++ b/pjsip/src/pjsip/sip_transport_udp.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -691,6 +691,8 @@ static pj_status_t register_to_ioqueue(struct udp_transport *tp)</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_grp_lock_add_ref(tp->grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_grp_lock_add_handler(tp->grp_lock, tp->base.pool, tp,</span><br><span style="color: hsl(120, 100%, 40%);">+ &udp_on_destroy);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ tp->base.grp_lock = tp->grp_lock;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Register to ioqueue. */</span><br><span style="color: hsl(120, 100%, 40%);">+-- </span><br><span style="color: hsl(120, 100%, 40%);">+2.20.1</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>diff --git a/third-party/pjproject/patches/0032-Re-2191-Fixed-crash-in-SIP-transport-destroy-due-to-.patch b/third-party/pjproject/patches/0032-Re-2191-Fixed-crash-in-SIP-transport-destroy-due-to-.patch</span><br><span>new file mode 100644</span><br><span>index 0000000..1c8d60f</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/pjproject/patches/0032-Re-2191-Fixed-crash-in-SIP-transport-destroy-due-to-.patch</span><br><span>@@ -0,0 +1,141 @@</span><br><span style="color: hsl(120, 100%, 40%);">+From 0de79e4bb4114b60155fe3641ff410f48d99bc1d Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(120, 100%, 40%);">+From: nanang <nanang@localhost></span><br><span style="color: hsl(120, 100%, 40%);">+Date: Wed, 15 May 2019 02:54:52 +0000</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: [PATCH] Re #2191: Fixed crash in SIP transport destroy due to bug</span><br><span style="color: hsl(120, 100%, 40%);">+ introduced by r5971, i.e: group lock is set after registering tp to tpmgr, so</span><br><span style="color: hsl(120, 100%, 40%);">+ tpmgr won't call pj_grp_lock_add_ref(), but in unregisteration, group lock is</span><br><span style="color: hsl(120, 100%, 40%);">+ set, so tpmgr will call pj_grp_lock_dec_ref().</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+---</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip/src/pjsip/sip_transport_tls.c | 29 +++++++++++------------------</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip/src/pjsip/sip_transport_udp.c | 21 +++++++++++++++------</span><br><span style="color: hsl(120, 100%, 40%);">+ 2 files changed, 26 insertions(+), 24 deletions(-)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 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(120, 100%, 40%);">+index a8468e092..466877edf 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjsip/src/pjsip/sip_transport_tls.c</span><br><span>++++ b/pjsip/src/pjsip/sip_transport_tls.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -162,6 +162,7 @@ static pj_status_t tls_create(struct tls_listener *listener,</span><br><span style="color: hsl(120, 100%, 40%);">+ const pj_sockaddr *local,</span><br><span style="color: hsl(120, 100%, 40%);">+ const pj_sockaddr *remote,</span><br><span style="color: hsl(120, 100%, 40%);">+ const pj_str_t *remote_name,</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_grp_lock_t *glock,</span><br><span style="color: hsl(120, 100%, 40%);">+ struct tls_transport **p_tls);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -786,6 +787,7 @@ static pj_status_t tls_create( struct tls_listener *listener,</span><br><span style="color: hsl(120, 100%, 40%);">+ const pj_sockaddr *local,</span><br><span style="color: hsl(120, 100%, 40%);">+ const pj_sockaddr *remote,</span><br><span style="color: hsl(120, 100%, 40%);">+ const pj_str_t *remote_name,</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_grp_lock_t *glock,</span><br><span style="color: hsl(120, 100%, 40%);">+ struct tls_transport **p_tls)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct tls_transport *tls;</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -870,6 +872,11 @@ static pj_status_t tls_create( struct tls_listener *listener,</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ tls->ssock = ssock;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++ /* Set up the group lock */</span><br><span style="color: hsl(120, 100%, 40%);">++ tls->grp_lock = tls->base.grp_lock = glock;</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_grp_lock_add_ref(tls->grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_grp_lock_add_handler(tls->grp_lock, pool, tls, &tls_on_destroy);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Register transport to transport manager */</span><br><span style="color: hsl(120, 100%, 40%);">+ status = pjsip_transport_register(listener->tpmgr, &tls->base);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (status != PJ_SUCCESS) {</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1226,20 +1233,13 @@ static pj_status_t lis_create_transport(pjsip_tpfactory *factory,</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Create the transport descriptor */</span><br><span style="color: hsl(120, 100%, 40%);">+ status = tls_create(listener, pool, ssock, PJ_FALSE, &local_addr, </span><br><span style="color: hsl(120, 100%, 40%);">+- rem_addr, &remote_name, &tls);</span><br><span style="color: hsl(120, 100%, 40%);">+- if (status != PJ_SUCCESS) {</span><br><span style="color: hsl(120, 100%, 40%);">+- pj_grp_lock_destroy(glock);</span><br><span style="color: hsl(120, 100%, 40%);">++ rem_addr, &remote_name, glock, &tls);</span><br><span style="color: hsl(120, 100%, 40%);">++ if (status != PJ_SUCCESS)</span><br><span style="color: hsl(120, 100%, 40%);">+ return status;</span><br><span style="color: hsl(120, 100%, 40%);">+- }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Set the "pending" SSL socket user data */</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_ssl_sock_set_user_data(tls->ssock, tls);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- /* Set up the group lock */</span><br><span style="color: hsl(120, 100%, 40%);">+- tls->grp_lock = tls->base.grp_lock = glock;</span><br><span style="color: hsl(120, 100%, 40%);">+- pj_grp_lock_add_ref(tls->grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">+- pj_grp_lock_add_handler(tls->grp_lock, pool, tls, &tls_on_destroy);</span><br><span style="color: hsl(120, 100%, 40%);">+-</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Start asynchronous connect() operation */</span><br><span style="color: hsl(120, 100%, 40%);">+ tls->has_pending_connect = PJ_TRUE;</span><br><span style="color: hsl(120, 100%, 40%);">+ status = pj_ssl_sock_start_connect(tls->ssock, tls->base.pool, </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1393,7 +1393,8 @@ static pj_bool_t on_accept_complete2(pj_ssl_sock_t *ssock,</span><br><span style="color: hsl(120, 100%, 40%);">+ * Create TLS transport for the new socket.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ status = tls_create( listener, NULL, new_ssock, PJ_TRUE,</span><br><span style="color: hsl(120, 100%, 40%);">+- &ssl_info.local_addr, &tmp_src_addr, NULL, &tls);</span><br><span style="color: hsl(120, 100%, 40%);">++ &ssl_info.local_addr, &tmp_src_addr, NULL,</span><br><span style="color: hsl(120, 100%, 40%);">++ ssl_info.grp_lock, &tls);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ if (status != PJ_SUCCESS) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (listener->tls_setting.on_accept_fail_cb) {</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1410,14 +1411,6 @@ static pj_bool_t on_accept_complete2(pj_ssl_sock_t *ssock,</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Set the "pending" SSL socket user data */</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_ssl_sock_set_user_data(new_ssock, tls);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- /* Set up the group lock */</span><br><span style="color: hsl(120, 100%, 40%);">+- if (ssl_info.grp_lock) {</span><br><span style="color: hsl(120, 100%, 40%);">+- tls->grp_lock = ssl_info.grp_lock;</span><br><span style="color: hsl(120, 100%, 40%);">+- pj_grp_lock_add_ref(tls->grp_lock);</span><br><span style="color: hsl(120, 100%, 40%);">+- pj_grp_lock_add_handler(tls->grp_lock, tls->base.pool, tls,</span><br><span style="color: hsl(120, 100%, 40%);">+- &tls_on_destroy);</span><br><span style="color: hsl(120, 100%, 40%);">+- }</span><br><span style="color: hsl(120, 100%, 40%);">+-</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Prevent immediate transport destroy as application may access it </span><br><span style="color: hsl(120, 100%, 40%);">+ * (getting info, etc) in transport state notification callback.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 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(120, 100%, 40%);">+index c02c48a03..905487dd9 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjsip/src/pjsip/sip_transport_udp.c</span><br><span>++++ b/pjsip/src/pjsip/sip_transport_udp.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -470,6 +470,16 @@ static pj_status_t udp_destroy( pjsip_transport *transport )</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++ /* When creating this transport, reference count was incremented to flag</span><br><span style="color: hsl(120, 100%, 40%);">++ * this transport as permanent so it will not be destroyed by transport</span><br><span style="color: hsl(120, 100%, 40%);">++ * manager whenever idle. Application may or may not have cleared the</span><br><span style="color: hsl(120, 100%, 40%);">++ * flag (by calling pjsip_transport_dec_ref()), so in case it has not,</span><br><span style="color: hsl(120, 100%, 40%);">++ * let's do it now, so this transport can be destroyed.</span><br><span style="color: hsl(120, 100%, 40%);">++ */</span><br><span style="color: hsl(120, 100%, 40%);">++ if (pj_atomic_get(tp->base.ref_cnt) > 0)</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_transport_dec_ref(&tp->base);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ /* Destroy transport */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (tp->grp_lock) {</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_grp_lock_t *grp_lock = tp->grp_lock;</span><br><span style="color: hsl(120, 100%, 40%);">+ tp->grp_lock = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -844,18 +854,17 @@ static pj_status_t transport_attach( pjsip_endpoint *endpt,</span><br><span style="color: hsl(120, 100%, 40%);">+ tp->base.do_shutdown = &udp_shutdown;</span><br><span style="color: hsl(120, 100%, 40%);">+ tp->base.destroy = &udp_destroy;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- /* This is a permanent transport, so we initialize the ref count</span><br><span style="color: hsl(120, 100%, 40%);">+- * to one so that transport manager don't destroy this transport</span><br><span style="color: hsl(120, 100%, 40%);">+- * when there's no user!</span><br><span style="color: hsl(120, 100%, 40%);">+- */</span><br><span style="color: hsl(120, 100%, 40%);">+- pj_atomic_inc(tp->base.ref_cnt);</span><br><span style="color: hsl(120, 100%, 40%);">+-</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Register to transport manager. */</span><br><span style="color: hsl(120, 100%, 40%);">+ tp->base.tpmgr = pjsip_endpt_get_tpmgr(endpt);</span><br><span style="color: hsl(120, 100%, 40%);">+ status = pjsip_transport_register( tp->base.tpmgr, (pjsip_transport*)tp);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (status != PJ_SUCCESS)</span><br><span style="color: hsl(120, 100%, 40%);">+ goto on_error;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++ /* This is a permanent transport, so we initialize the ref count</span><br><span style="color: hsl(120, 100%, 40%);">++ * to one so that transport manager won't destroy this transport</span><br><span style="color: hsl(120, 100%, 40%);">++ * when there's no user!</span><br><span style="color: hsl(120, 100%, 40%);">++ */</span><br><span style="color: hsl(120, 100%, 40%);">++ pjsip_transport_add_ref(&tp->base);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Create rdata and put it in the array. */</span><br><span style="color: hsl(120, 100%, 40%);">+ tp->rdata_cnt = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+-- </span><br><span style="color: hsl(120, 100%, 40%);">+2.21.0</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11391">change 11391</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/+/11391"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I2e09aa66de0dda9414d8a8259a649c4d2d96a9f5 </div>
<div style="display:none"> Gerrit-Change-Number: 11391 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>