<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11470">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjproject: Update to 2.9 release<br><br>Relies on https://github.com/asterisk/third-party/pull/4<br><br>Change-Id: Iec9cad42cb4ae109a86a3d4dae61e8bce4424ce3<br>---<br>D third-party/pjproject/patches/0010-outgoing_connected_line_method_update.patch<br>D third-party/pjproject/patches/0020-Fixed-2172-Avoid-double-reference-counter-decrements.patch<br>D third-party/pjproject/patches/0030-Re-2176-Removed-pop_freelist-push_freelist-after-rem.patch<br>D third-party/pjproject/patches/0031-Re-2191-transport-timer-cleanup.patch<br>D third-party/pjproject/patches/0032-Re-2191-Fixed-crash-in-SIP-transport-destroy-due-to-.patch<br>D third-party/pjproject/pjproject-2.8.tar.bz2.md5<br>A third-party/pjproject/pjproject-2.9.tar.bz2.md5<br>M third-party/versions.mak<br>8 files changed, 3 insertions(+), 628 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/70/11470/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/third-party/pjproject/patches/0010-outgoing_connected_line_method_update.patch b/third-party/pjproject/patches/0010-outgoing_connected_line_method_update.patch</span><br><span>deleted file mode 100644</span><br><span>index 218c544..0000000</span><br><span>--- a/third-party/pjproject/patches/0010-outgoing_connected_line_method_update.patch</span><br><span>+++ /dev/null</span><br><span>@@ -1,33 +0,0 @@</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c</span><br><span>---- a/pjsip/src/pjsip-ua/sip_inv.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/src/pjsip-ua/sip_inv.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -4185,6 +4185,29 @@</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- if (tsx->status_code != 100) {</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-+ if (inv->role == PJSIP_ROLE_UAC) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_rx_data *rdata = e->body.tsx_state.src.rdata;</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_allow_hdr *allow = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_msg *msg = rdata->msg_info.msg;</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (msg) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ allow = (pjsip_allow_hdr*) pjsip_msg_find_hdr(msg, PJSIP_H_ALLOW,</span><br><span style="color: hsl(0, 100%, 40%);">-+ NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-+ }</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (allow) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ unsigned i;</span><br><span style="color: hsl(0, 100%, 40%);">-+ const pj_str_t STR_UPDATE = { "UPDATE", 6 };</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ for (i=0; i<allow->count; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (pj_stricmp(&allow->values[i], &STR_UPDATE)==0) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* UPDATE is present in Allow */</span><br><span style="color: hsl(0, 100%, 40%);">-+ inv->options |= PJSIP_INV_SUPPORT_UPDATE;</span><br><span style="color: hsl(0, 100%, 40%);">-+ break;</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%);">-+ }</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- if (dlg->remote.info->tag.slen)</span><br><span style="color: hsl(0, 100%, 40%);">- inv_set_state(inv, PJSIP_INV_STATE_EARLY, e);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span>diff --git a/third-party/pjproject/patches/0020-Fixed-2172-Avoid-double-reference-counter-decrements.patch b/third-party/pjproject/patches/0020-Fixed-2172-Avoid-double-reference-counter-decrements.patch</span><br><span>deleted file mode 100644</span><br><span>index e394506..0000000</span><br><span>--- a/third-party/pjproject/patches/0020-Fixed-2172-Avoid-double-reference-counter-decrements.patch</span><br><span>+++ /dev/null</span><br><span>@@ -1,42 +0,0 @@</span><br><span style="color: hsl(0, 100%, 40%);">-From 1fed39fe1488abd654a5488b5e6ad59b4b973331 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, 8 Jan 2019 09:07:47 +0000</span><br><span style="color: hsl(0, 100%, 40%);">-Subject: [PATCH 1/5] Fixed #2172: Avoid double reference counter decrements in</span><br><span style="color: hsl(0, 100%, 40%);">- timer in the scenario of race condition between pj_timer_heap_cancel() and</span><br><span style="color: hsl(0, 100%, 40%);">- pj_timer_heap_poll().</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>----</span><br><span style="color: hsl(0, 100%, 40%);">- pjlib/src/pj/timer.c | 17 ++++++++++-------</span><br><span style="color: hsl(0, 100%, 40%);">- 1 file changed, 10 insertions(+), 7 deletions(-)</span><br><span style="color: hsl(0, 100%, 40%);">-</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 90a95e37b..7bae084ef 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%);">-@@ -580,13 +580,16 @@ static int cancel_timer(pj_timer_heap_t *ht,</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%);">- count = cancel(ht, entry, flags | F_DONT_CALL);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (flags & F_SET_ID) {</span><br><span style="color: hsl(0, 100%, 40%);">-- entry->id = id_val;</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-- if (entry->_grp_lock) {</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_grp_lock_t *grp_lock = entry->_grp_lock;</span><br><span style="color: hsl(0, 100%, 40%);">-- entry->_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%);">-+ if (count > 0) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Timer entry found & cancelled */</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (flags & F_SET_ID) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ entry->id = id_val;</span><br><span style="color: hsl(0, 100%, 40%);">-+ }</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (entry->_grp_lock) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_grp_lock_t *grp_lock = entry->_grp_lock;</span><br><span style="color: hsl(0, 100%, 40%);">-+ entry->_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%);">-+ }</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- unlock_timer_heap(ht);</span><br><span style="color: hsl(0, 100%, 40%);">- </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>diff --git a/third-party/pjproject/patches/0030-Re-2176-Removed-pop_freelist-push_freelist-after-rem.patch b/third-party/pjproject/patches/0030-Re-2176-Removed-pop_freelist-push_freelist-after-rem.patch</span><br><span>deleted file mode 100644</span><br><span>index 8a44cae..0000000</span><br><span>--- a/third-party/pjproject/patches/0030-Re-2176-Removed-pop_freelist-push_freelist-after-rem.patch</span><br><span>+++ /dev/null</span><br><span>@@ -1,37 +0,0 @@</span><br><span style="color: hsl(0, 100%, 40%);">-From 9f57a5728aaec1949908bf7bbd15768fce74e315 Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(0, 100%, 40%);">-From: Nanang Izzuddin <nanang@teluu.com></span><br><span style="color: hsl(0, 100%, 40%);">-Date: Wed, 13 Feb 2019 06:51:09 +0000</span><br><span style="color: hsl(0, 100%, 40%);">-Subject: [PATCH] Re #2176: Removed pop_freelist() + push_freelist() after</span><br><span style="color: hsl(0, 100%, 40%);">- remove_node() as they are not only unnecessary, they cause problem.</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@5934 74dad513-b988-da41-8d7b-12977e46ad98</span><br><span>----</span><br><span style="color: hsl(0, 100%, 40%);">- pjlib/src/pj/timer.c | 5 +++--</span><br><span style="color: hsl(0, 100%, 40%);">- 1 file changed, 3 insertions(+), 2 deletions(-)</span><br><span style="color: hsl(0, 100%, 40%);">-</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 90a95e37..a1e1932c 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%);">-@@ -630,7 +630,8 @@ PJ_DEF(unsigned) pj_timer_heap_poll( pj_timer_heap_t *ht,</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_timer_entry *node = remove_node(ht, 0);</span><br><span style="color: hsl(0, 100%, 40%);">- /* Avoid re-use of this timer until the callback is done. */</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_timer_id_t node_timer_id = pop_freelist(ht);</span><br><span style="color: hsl(0, 100%, 40%);">-+ ///Not necessary, even causes problem (see also #2176).</span><br><span style="color: hsl(0, 100%, 40%);">-+ ///pj_timer_id_t node_timer_id = pop_freelist(ht);</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%);">- ++count;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -650,7 +651,7 @@ PJ_DEF(unsigned) pj_timer_heap_poll( pj_timer_heap_t *ht,</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%);">- /* Now, the timer is really free for re-use. */</span><br><span style="color: hsl(0, 100%, 40%);">-- push_freelist(ht, node_timer_id);</span><br><span style="color: hsl(0, 100%, 40%);">-+ ///push_freelist(ht, node_timer_id);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- if (ht->cur_size && next_delay) {</span><br><span style="color: hsl(0, 100%, 40%);">- *next_delay = ht->heap[0]->_timer_value;</span><br><span>--- </span><br><span style="color: hsl(0, 100%, 40%);">-2.17.1</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><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>deleted file mode 100644</span><br><span>index e1205f0..0000000</span><br><span>--- a/third-party/pjproject/patches/0031-Re-2191-transport-timer-cleanup.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>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>deleted file mode 100644</span><br><span>index 1c8d60f..0000000</span><br><span>--- a/third-party/pjproject/patches/0032-Re-2191-Fixed-crash-in-SIP-transport-destroy-due-to-.patch</span><br><span>+++ /dev/null</span><br><span>@@ -1,141 +0,0 @@</span><br><span style="color: hsl(0, 100%, 40%);">-From 0de79e4bb4114b60155fe3641ff410f48d99bc1d 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: Wed, 15 May 2019 02:54:52 +0000</span><br><span style="color: hsl(0, 100%, 40%);">-Subject: [PATCH] Re #2191: Fixed crash in SIP transport destroy due to bug</span><br><span style="color: hsl(0, 100%, 40%);">- introduced by r5971, i.e: group lock is set after registering tp to tpmgr, so</span><br><span style="color: hsl(0, 100%, 40%);">- tpmgr won't call pj_grp_lock_add_ref(), but in unregisteration, group lock is</span><br><span style="color: hsl(0, 100%, 40%);">- set, so tpmgr will call pj_grp_lock_dec_ref().</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>----</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/pjsip/sip_transport_tls.c | 29 +++++++++++------------------</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/pjsip/sip_transport_udp.c | 21 +++++++++++++++------</span><br><span style="color: hsl(0, 100%, 40%);">- 2 files changed, 26 insertions(+), 24 deletions(-)</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_tls.c b/pjsip/src/pjsip/sip_transport_tls.c</span><br><span style="color: hsl(0, 100%, 40%);">-index a8468e092..466877edf 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%);">-@@ -162,6 +162,7 @@ static pj_status_t tls_create(struct tls_listener *listener,</span><br><span style="color: hsl(0, 100%, 40%);">- const pj_sockaddr *local,</span><br><span style="color: hsl(0, 100%, 40%);">- const pj_sockaddr *remote,</span><br><span style="color: hsl(0, 100%, 40%);">- const pj_str_t *remote_name,</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_grp_lock_t *glock,</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%);">-@@ -786,6 +787,7 @@ static pj_status_t tls_create( struct tls_listener *listener,</span><br><span style="color: hsl(0, 100%, 40%);">- const pj_sockaddr *local,</span><br><span style="color: hsl(0, 100%, 40%);">- const pj_sockaddr *remote,</span><br><span style="color: hsl(0, 100%, 40%);">- const pj_str_t *remote_name,</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_grp_lock_t *glock,</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%);">- struct tls_transport *tls;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -870,6 +872,11 @@ static pj_status_t tls_create( struct tls_listener *listener,</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- tls->ssock = ssock;</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 = 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%);">- /* Register transport to transport manager */</span><br><span style="color: hsl(0, 100%, 40%);">- status = pjsip_transport_register(listener->tpmgr, &tls->base);</span><br><span style="color: hsl(0, 100%, 40%);">- if (status != PJ_SUCCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1226,20 +1233,13 @@ static pj_status_t lis_create_transport(pjsip_tpfactory *factory,</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /* Create the transport descriptor */</span><br><span style="color: hsl(0, 100%, 40%);">- status = tls_create(listener, pool, ssock, PJ_FALSE, &local_addr, </span><br><span style="color: hsl(0, 100%, 40%);">-- rem_addr, &remote_name, &tls);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (status != PJ_SUCCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_grp_lock_destroy(glock);</span><br><span style="color: hsl(0, 100%, 40%);">-+ rem_addr, &remote_name, glock, &tls);</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (status != PJ_SUCCESS)</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%);">- /* Set the "pending" SSL socket user data */</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 = 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%);">- /* Start asynchronous connect() operation */</span><br><span style="color: hsl(0, 100%, 40%);">- tls->has_pending_connect = PJ_TRUE;</span><br><span style="color: hsl(0, 100%, 40%);">- status = pj_ssl_sock_start_connect(tls->ssock, tls->base.pool, </span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1393,7 +1393,8 @@ static pj_bool_t on_accept_complete2(pj_ssl_sock_t *ssock,</span><br><span style="color: hsl(0, 100%, 40%);">- * Create TLS transport for the new socket.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- status = tls_create( listener, NULL, new_ssock, PJ_TRUE,</span><br><span style="color: hsl(0, 100%, 40%);">-- &ssl_info.local_addr, &tmp_src_addr, NULL, &tls);</span><br><span style="color: hsl(0, 100%, 40%);">-+ &ssl_info.local_addr, &tmp_src_addr, NULL,</span><br><span style="color: hsl(0, 100%, 40%);">-+ ssl_info.grp_lock, &tls);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- if (status != PJ_SUCCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (listener->tls_setting.on_accept_fail_cb) {</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1410,14 +1411,6 @@ static pj_bool_t on_accept_complete2(pj_ssl_sock_t *ssock,</span><br><span style="color: hsl(0, 100%, 40%);">- /* Set the "pending" SSL socket user data */</span><br><span style="color: hsl(0, 100%, 40%);">- pj_ssl_sock_set_user_data(new_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%);">-- if (ssl_info.grp_lock) {</span><br><span style="color: hsl(0, 100%, 40%);">-- tls->grp_lock = ssl_info.grp_lock;</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, tls->base.pool, tls,</span><br><span style="color: hsl(0, 100%, 40%);">-- &tls_on_destroy);</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%);">- /* Prevent immediate transport destroy as application may access it </span><br><span style="color: hsl(0, 100%, 40%);">- * (getting info, etc) in transport state notification callback.</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 c02c48a03..905487dd9 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%);">-@@ -470,6 +470,16 @@ static pj_status_t udp_destroy( pjsip_transport *transport )</span><br><span style="color: hsl(0, 100%, 40%);">- break;</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%);">-+ /* When creating this transport, reference count was incremented to flag</span><br><span style="color: hsl(0, 100%, 40%);">-+ * this transport as permanent so it will not be destroyed by transport</span><br><span style="color: hsl(0, 100%, 40%);">-+ * manager whenever idle. Application may or may not have cleared the</span><br><span style="color: hsl(0, 100%, 40%);">-+ * flag (by calling pjsip_transport_dec_ref()), so in case it has not,</span><br><span style="color: hsl(0, 100%, 40%);">-+ * let's do it now, so this transport can be destroyed.</span><br><span style="color: hsl(0, 100%, 40%);">-+ */</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (pj_atomic_get(tp->base.ref_cnt) > 0)</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_transport_dec_ref(&tp->base);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Destroy transport */</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_t *grp_lock = tp->grp_lock;</span><br><span style="color: hsl(0, 100%, 40%);">- tp->grp_lock = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -844,18 +854,17 @@ static pj_status_t transport_attach( pjsip_endpoint *endpt,</span><br><span style="color: hsl(0, 100%, 40%);">- tp->base.do_shutdown = &udp_shutdown;</span><br><span style="color: hsl(0, 100%, 40%);">- tp->base.destroy = &udp_destroy;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- /* This is a permanent transport, so we initialize the ref count</span><br><span style="color: hsl(0, 100%, 40%);">-- * to one so that transport manager don't destroy this transport</span><br><span style="color: hsl(0, 100%, 40%);">-- * when there's no user!</span><br><span style="color: hsl(0, 100%, 40%);">-- */</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_atomic_inc(tp->base.ref_cnt);</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">- /* Register to transport manager. */</span><br><span style="color: hsl(0, 100%, 40%);">- tp->base.tpmgr = pjsip_endpt_get_tpmgr(endpt);</span><br><span style="color: hsl(0, 100%, 40%);">- status = pjsip_transport_register( tp->base.tpmgr, (pjsip_transport*)tp);</span><br><span style="color: hsl(0, 100%, 40%);">- if (status != PJ_SUCCESS)</span><br><span style="color: hsl(0, 100%, 40%);">- goto on_error;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-+ /* This is a permanent transport, so we initialize the ref count</span><br><span style="color: hsl(0, 100%, 40%);">-+ * to one so that transport manager won't destroy this transport</span><br><span style="color: hsl(0, 100%, 40%);">-+ * when there's no user!</span><br><span style="color: hsl(0, 100%, 40%);">-+ */</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_transport_add_ref(&tp->base);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /* Create rdata and put it in the array. */</span><br><span style="color: hsl(0, 100%, 40%);">- tp->rdata_cnt = 0;</span><br><span>--- </span><br><span style="color: hsl(0, 100%, 40%);">-2.21.0</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>diff --git a/third-party/pjproject/pjproject-2.8.tar.bz2.md5 b/third-party/pjproject/pjproject-2.8.tar.bz2.md5</span><br><span>deleted file mode 100644</span><br><span>index 5e3e7f6..0000000</span><br><span>--- a/third-party/pjproject/pjproject-2.8.tar.bz2.md5</span><br><span>+++ /dev/null</span><br><span>@@ -1,2 +0,0 @@</span><br><span style="color: hsl(0, 100%, 40%);">-1d3cb8fd2752c724dc8798900f102e75 *pjproject-2.8.zip</span><br><span style="color: hsl(0, 100%, 40%);">-6487d54213f270d307eaa60efc9f56f3 pjproject-2.8.tar.bz2</span><br><span>\ No newline at end of file</span><br><span>diff --git a/third-party/pjproject/pjproject-2.9.tar.bz2.md5 b/third-party/pjproject/pjproject-2.9.tar.bz2.md5</span><br><span>new file mode 100644</span><br><span>index 0000000..5e11195</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/pjproject/pjproject-2.9.tar.bz2.md5</span><br><span>@@ -0,0 +1,2 @@</span><br><span style="color: hsl(120, 100%, 40%);">+e4ec23a6bfa06fb53c313aa7fed81236 *pjproject-2.9.zip</span><br><span style="color: hsl(120, 100%, 40%);">+66757078e7bd7cf316acb0425c2fdd6f pjproject-2.9.tar.bz2</span><br><span>\ No newline at end of file</span><br><span>diff --git a/third-party/versions.mak b/third-party/versions.mak</span><br><span>index c265adc..103ac58 100644</span><br><span>--- a/third-party/versions.mak</span><br><span>+++ b/third-party/versions.mak</span><br><span>@@ -1,2 +1,2 @@</span><br><span> JANSSON_VERSION = 2.12</span><br><span style="color: hsl(0, 100%, 40%);">-PJPROJECT_VERSION = 2.8</span><br><span style="color: hsl(120, 100%, 40%);">+PJPROJECT_VERSION = 2.9</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11470">change 11470</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/+/11470"/><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: Iec9cad42cb4ae109a86a3d4dae61e8bce4424ce3 </div>
<div style="display:none"> Gerrit-Change-Number: 11470 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>