<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13039">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Sean Bright: Looks good to me, but someone else must approve
Michael L. Young: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjproject_bundled: Replace earlier reverts with official fixes.<br><br>Issues in pjproject 2.9 caused us to revert some of their changes<br>as a work around. This introduced another issue where pjproject<br>wouldn't build with older gcc versions such as that found on<br>CentOS 6. This commit replaces the reverts with the official<br>fixes for the original issues and allows pjproject to be built<br>on CentOS 6 again.<br><br>ASTERISK-28574<br>Reported-by: Niklas Larsson<br><br>Change-Id: I06f8507bea553d1a01b0b8874197d35b9d47ec4c<br>---<br>D third-party/pjproject/patches/0030-Revert-Misc-re-2147-Fixed-warnings-in-SSL-socket-red.patch<br>A third-party/pjproject/patches/0030-ssl-regression-fix.patch<br>D third-party/pjproject/patches/0031-Revert-Fixed-2204-Add-OpenSSL-remote-certificate-cha.patch<br>A third-party/pjproject/patches/0031-transport-regression-fix.patch<br>D third-party/pjproject/patches/0032-Revert-Re-2147-misc-Fix-failed-pjsip-test-transport_.patch<br>D third-party/pjproject/patches/0033-Revert-Close-1019-Support-for-multiple-listeners.patch<br>6 files changed, 292 insertions(+), 1,302 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/third-party/pjproject/patches/0030-Revert-Misc-re-2147-Fixed-warnings-in-SSL-socket-red.patch b/third-party/pjproject/patches/0030-Revert-Misc-re-2147-Fixed-warnings-in-SSL-socket-red.patch</span><br><span>deleted file mode 100644</span><br><span>index 4c39fc0..0000000</span><br><span>--- a/third-party/pjproject/patches/0030-Revert-Misc-re-2147-Fixed-warnings-in-SSL-socket-red.patch</span><br><span>+++ /dev/null</span><br><span>@@ -1,60 +0,0 @@</span><br><span style="color: hsl(0, 100%, 40%);">-From 8d0652d4a02c7b8da58b1b98421cfda57056184d Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(0, 100%, 40%);">-From: George Joseph <gjoseph@digium.com></span><br><span style="color: hsl(0, 100%, 40%);">-Date: Tue, 24 Sep 2019 06:41:16 -0600</span><br><span style="color: hsl(0, 100%, 40%);">-Subject: [PATCH 30/33] Revert "Misc (re #2147): Fixed warnings in SSL socket:</span><br><span style="color: hsl(0, 100%, 40%);">- redefinition of typedef 'pj_ssl_sock_t' and unused 'get_pem'."</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-This reverts commit 688a9b0de685328f62b2df86304b44c21e4460ae.</span><br><span>----</span><br><span style="color: hsl(0, 100%, 40%);">- pjlib/src/pj/ssl_sock_imp_common.h | 4 ++--</span><br><span style="color: hsl(0, 100%, 40%);">- pjlib/src/pj/ssl_sock_ossl.c | 5 +----</span><br><span style="color: hsl(0, 100%, 40%);">- 2 files changed, 3 insertions(+), 6 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/ssl_sock_imp_common.h b/pjlib/src/pj/ssl_sock_imp_common.h</span><br><span style="color: hsl(0, 100%, 40%);">-index 09f259ef7..4edbb3b82 100644</span><br><span>---- a/pjlib/src/pj/ssl_sock_imp_common.h</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjlib/src/pj/ssl_sock_imp_common.h</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -93,7 +93,7 @@ typedef struct circ_buf_t {</span><br><span style="color: hsl(0, 100%, 40%);">- /*</span><br><span style="color: hsl(0, 100%, 40%);">- * Secure socket structure definition.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">--struct pj_ssl_sock_t</span><br><span style="color: hsl(0, 100%, 40%);">-+typedef struct pj_ssl_sock_t</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_pool_t *pool;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_ssl_sock_t *parent;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -139,7 +139,7 @@ struct pj_ssl_sock_t</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- circ_buf_t circ_buf_output;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_lock_t *circ_buf_output_mutex;</span><br><span style="color: hsl(0, 100%, 40%);">--};</span><br><span style="color: hsl(0, 100%, 40%);">-+} pj_ssl_sock_t;</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%);">-diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c</span><br><span style="color: hsl(0, 100%, 40%);">-index b4ac5c15f..debb105b1 100644</span><br><span>---- a/pjlib/src/pj/ssl_sock_ossl.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjlib/src/pj/ssl_sock_ossl.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -37,6 +37,7 @@</span><br><span style="color: hsl(0, 100%, 40%);">- #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0 && \</span><br><span style="color: hsl(0, 100%, 40%);">- (PJ_SSL_SOCK_IMP == PJ_SSL_SOCK_IMP_OPENSSL)</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-+#include "ssl_sock_imp_common.h"</span><br><span style="color: hsl(0, 100%, 40%);">- #include "ssl_sock_imp_common.c"</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- #define THIS_FILE "ssl_sock_ossl.c"</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1575,10 +1576,6 @@ static void ssl_update_remote_cert_chain_info(pj_pool_t *pool,</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">- int i;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- /* For now, get_pem has to be PJ_TRUE */</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_assert(get_pem);</span><br><span style="color: hsl(0, 100%, 40%);">-- PJ_UNUSED_ARG(get_pem);</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">- ci->raw_chain.cert_raw = (pj_str_t *)pj_pool_calloc(pool,</span><br><span style="color: hsl(0, 100%, 40%);">- sk_X509_num(chain),</span><br><span style="color: hsl(0, 100%, 40%);">- sizeof(pj_str_t));</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/patches/0030-ssl-regression-fix.patch b/third-party/pjproject/patches/0030-ssl-regression-fix.patch</span><br><span>new file mode 100644</span><br><span>index 0000000..8ddcaf7</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/pjproject/patches/0030-ssl-regression-fix.patch</span><br><span>@@ -0,0 +1,105 @@</span><br><span style="color: hsl(120, 100%, 40%);">+From 489281f29fc7b97143cf79154f22e5007adaba39 Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(120, 100%, 40%);">+From: George Joseph <gjoseph@digium.com></span><br><span style="color: hsl(120, 100%, 40%);">+Date: Wed, 9 Oct 2019 07:49:44 -0600</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: [PATCH 30/31] ssl regression fix</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/src/pj/ssl_sock_gtls.c | 6 ++++--</span><br><span style="color: hsl(120, 100%, 40%);">+ pjlib/src/pj/ssl_sock_imp_common.c | 4 ++++</span><br><span style="color: hsl(120, 100%, 40%);">+ pjlib/src/pj/ssl_sock_imp_common.h | 3 +++</span><br><span style="color: hsl(120, 100%, 40%);">+ pjlib/src/pj/ssl_sock_ossl.c | 9 +++++----</span><br><span style="color: hsl(120, 100%, 40%);">+ 4 files changed, 16 insertions(+), 6 deletions(-)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjlib/src/pj/ssl_sock_gtls.c b/pjlib/src/pj/ssl_sock_gtls.c</span><br><span style="color: hsl(120, 100%, 40%);">+index 311b7b757..484770ae4 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjlib/src/pj/ssl_sock_gtls.c</span><br><span>++++ b/pjlib/src/pj/ssl_sock_gtls.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1050,7 +1050,8 @@ static void ssl_update_certs_info(pj_ssl_sock_t *ssock)</span><br><span style="color: hsl(120, 100%, 40%);">+ goto us_out;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ tls_cert_get_info(ssock->pool, &ssock->local_cert_info, cert);</span><br><span style="color: hsl(120, 100%, 40%);">+- tls_cert_get_chain_raw(ssock->pool, &ssock->local_cert_info, us, 1);</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_pool_reset(ssock->info_pool);</span><br><span style="color: hsl(120, 100%, 40%);">++ tls_cert_get_chain_raw(ssock->info_pool, &ssock->local_cert_info, us, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ us_out:</span><br><span style="color: hsl(120, 100%, 40%);">+ tls_last_error = ret;</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1077,7 +1078,8 @@ us_out:</span><br><span style="color: hsl(120, 100%, 40%);">+ goto peer_out;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ tls_cert_get_info(ssock->pool, &ssock->remote_cert_info, cert);</span><br><span style="color: hsl(120, 100%, 40%);">+- tls_cert_get_chain_raw(ssock->pool, &ssock->remote_cert_info, certs,</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_pool_reset(ssock->info_pool);</span><br><span style="color: hsl(120, 100%, 40%);">++ tls_cert_get_chain_raw(ssock->info_pool, &ssock->remote_cert_info, certs,</span><br><span style="color: hsl(120, 100%, 40%);">+ certslen);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ peer_out:</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjlib/src/pj/ssl_sock_imp_common.c b/pjlib/src/pj/ssl_sock_imp_common.c</span><br><span style="color: hsl(120, 100%, 40%);">+index e6273d832..51a62a2fb 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjlib/src/pj/ssl_sock_imp_common.c</span><br><span>++++ b/pjlib/src/pj/ssl_sock_imp_common.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -616,6 +616,7 @@ static void ssl_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%);">+ /* Secure release pool, i.e: all memory blocks will be zeroed first */</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_pool_secure_release(&ssock->info_pool);</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_pool_secure_release(&ssock->pool);</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%);">+@@ -1262,15 +1263,18 @@ PJ_DEF(pj_status_t) pj_ssl_sock_create (pj_pool_t *pool,</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_ssl_sock_t *ssock;</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_status_t status;</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_pool_t *info_pool;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ PJ_ASSERT_RETURN(pool && param && p_ssock, PJ_EINVAL);</span><br><span style="color: hsl(120, 100%, 40%);">+ PJ_ASSERT_RETURN(param->sock_type == pj_SOCK_STREAM(), PJ_ENOTSUP);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++ info_pool = pj_pool_create(pool->factory, "ssl_chain%p", 512, 512, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ pool = pj_pool_create(pool->factory, "ssl%p", 512, 512, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Create secure socket */</span><br><span style="color: hsl(120, 100%, 40%);">+ ssock = ssl_alloc(pool);</span><br><span style="color: hsl(120, 100%, 40%);">+ ssock->pool = pool;</span><br><span style="color: hsl(120, 100%, 40%);">++ ssock->info_pool = info_pool;</span><br><span style="color: hsl(120, 100%, 40%);">+ ssock->sock = PJ_INVALID_SOCKET;</span><br><span style="color: hsl(120, 100%, 40%);">+ ssock->ssl_state = SSL_STATE_NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ ssock->circ_buf_input.owner = ssock;</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjlib/src/pj/ssl_sock_imp_common.h b/pjlib/src/pj/ssl_sock_imp_common.h</span><br><span style="color: hsl(120, 100%, 40%);">+index 09f259ef7..eb45f14e0 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjlib/src/pj/ssl_sock_imp_common.h</span><br><span>++++ b/pjlib/src/pj/ssl_sock_imp_common.h</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -96,6 +96,9 @@ typedef struct circ_buf_t {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct pj_ssl_sock_t</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_pool_t *pool;</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_pool_t *info_pool; /* this is for certificate chain </span><br><span style="color: hsl(120, 100%, 40%);">++ * information allocation. Don't use for </span><br><span style="color: hsl(120, 100%, 40%);">++ * other purposes. */</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_ssl_sock_t *parent;</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_ssl_sock_param param;</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_ssl_sock_param newsock_param;</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c</span><br><span style="color: hsl(120, 100%, 40%);">+index b4ac5c15f..2545b7c37 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/pjlib/src/pj/ssl_sock_ossl.c</span><br><span>++++ b/pjlib/src/pj/ssl_sock_ossl.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1637,11 +1637,12 @@ static void ssl_update_certs_info(pj_ssl_sock_t *ssock)</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ chain = SSL_get_peer_cert_chain(ossock->ossl_ssl);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (chain) {</span><br><span style="color: hsl(120, 100%, 40%);">+- ssl_update_remote_cert_chain_info(ssock->pool,</span><br><span style="color: hsl(120, 100%, 40%);">+- &ssock->remote_cert_info,</span><br><span style="color: hsl(120, 100%, 40%);">+- chain, PJ_TRUE);</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_pool_reset(ssock->info_pool);</span><br><span style="color: hsl(120, 100%, 40%);">++ ssl_update_remote_cert_chain_info(ssock->info_pool,</span><br><span style="color: hsl(120, 100%, 40%);">++ &ssock->remote_cert_info,</span><br><span style="color: hsl(120, 100%, 40%);">++ chain, PJ_TRUE);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+- ssock->remote_cert_info.raw_chain.cnt = 0;</span><br><span style="color: hsl(120, 100%, 40%);">++ ssock->remote_cert_info.raw_chain.cnt = 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%);">+ </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>diff --git a/third-party/pjproject/patches/0031-Revert-Fixed-2204-Add-OpenSSL-remote-certificate-cha.patch b/third-party/pjproject/patches/0031-Revert-Fixed-2204-Add-OpenSSL-remote-certificate-cha.patch</span><br><span>deleted file mode 100644</span><br><span>index b39c4d7..0000000</span><br><span>--- a/third-party/pjproject/patches/0031-Revert-Fixed-2204-Add-OpenSSL-remote-certificate-cha.patch</span><br><span>+++ /dev/null</span><br><span>@@ -1,84 +0,0 @@</span><br><span style="color: hsl(0, 100%, 40%);">-From 616a13933f33a6d74f84d85b5bfb858279a09e2d Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(0, 100%, 40%);">-From: George Joseph <gjoseph@digium.com></span><br><span style="color: hsl(0, 100%, 40%);">-Date: Tue, 24 Sep 2019 06:42:04 -0600</span><br><span style="color: hsl(0, 100%, 40%);">-Subject: [PATCH 31/33] Revert "Fixed #2204: Add OpenSSL remote certificate</span><br><span style="color: hsl(0, 100%, 40%);">- chain info"</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-This reverts commit f71d60c866c4572a7c8398fe982416771fc6a7f5.</span><br><span>----</span><br><span style="color: hsl(0, 100%, 40%);">- pjlib/src/pj/ssl_sock_ossl.c | 45 ------------------------------------</span><br><span style="color: hsl(0, 100%, 40%);">- 1 file changed, 45 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/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c</span><br><span style="color: hsl(0, 100%, 40%);">-index debb105b1..109c5c1e2 100644</span><br><span>---- a/pjlib/src/pj/ssl_sock_ossl.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjlib/src/pj/ssl_sock_ossl.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1566,41 +1566,6 @@ static void get_cert_info(pj_pool_t *pool, pj_ssl_cert_info *ci, X509 *x,</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%);">--/* Update remote certificates chain info. This function should be</span><br><span style="color: hsl(0, 100%, 40%);">-- * called after handshake or renegotiation successfully completed.</span><br><span style="color: hsl(0, 100%, 40%);">-- */</span><br><span style="color: hsl(0, 100%, 40%);">--static void ssl_update_remote_cert_chain_info(pj_pool_t *pool,</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_ssl_cert_info *ci,</span><br><span style="color: hsl(0, 100%, 40%);">-- STACK_OF(X509) *chain,</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_bool_t get_pem)</span><br><span style="color: hsl(0, 100%, 40%);">--{</span><br><span style="color: hsl(0, 100%, 40%);">-- int i;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- ci->raw_chain.cert_raw = (pj_str_t *)pj_pool_calloc(pool,</span><br><span style="color: hsl(0, 100%, 40%);">-- sk_X509_num(chain),</span><br><span style="color: hsl(0, 100%, 40%);">-- sizeof(pj_str_t));</span><br><span style="color: hsl(0, 100%, 40%);">-- ci->raw_chain.cnt = sk_X509_num(chain);</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- for (i = 0; i < sk_X509_num(chain); i++) {</span><br><span style="color: hsl(0, 100%, 40%);">-- BIO *bio;</span><br><span style="color: hsl(0, 100%, 40%);">-- BUF_MEM *ptr;</span><br><span style="color: hsl(0, 100%, 40%);">-- X509 *x = sk_X509_value(chain, i);</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- bio = BIO_new(BIO_s_mem());</span><br><span style="color: hsl(0, 100%, 40%);">-- </span><br><span style="color: hsl(0, 100%, 40%);">-- if (!PEM_write_bio_X509(bio, x)) {</span><br><span style="color: hsl(0, 100%, 40%);">-- PJ_LOG(3, (THIS_FILE, "Error retrieving raw certificate info"));</span><br><span style="color: hsl(0, 100%, 40%);">-- ci->raw_chain.cert_raw[i].ptr = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-- ci->raw_chain.cert_raw[i].slen = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-- } else {</span><br><span style="color: hsl(0, 100%, 40%);">-- BIO_write(bio, "\0", 1);</span><br><span style="color: hsl(0, 100%, 40%);">-- BIO_get_mem_ptr(bio, &ptr);</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_strdup2(pool, &ci->raw_chain.cert_raw[i], ptr->data );</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%);">-- BIO_free(bio);</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%);">- /* Update local & remote certificates info. This function should be</span><br><span style="color: hsl(0, 100%, 40%);">- * called after handshake or renegotiation successfully completed.</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1609,7 +1574,6 @@ static void ssl_update_certs_info(pj_ssl_sock_t *ssock)</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">- ossl_sock_t *ossock = (ossl_sock_t *)ssock;</span><br><span style="color: hsl(0, 100%, 40%);">- X509 *x;</span><br><span style="color: hsl(0, 100%, 40%);">-- STACK_OF(X509) *chain;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- pj_assert(ssock->ssl_state == SSL_STATE_ESTABLISHED);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1631,15 +1595,6 @@ static void ssl_update_certs_info(pj_ssl_sock_t *ssock)</span><br><span style="color: hsl(0, 100%, 40%);">- } else {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_bzero(&ssock->remote_cert_info, sizeof(pj_ssl_cert_info));</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%);">-- chain = SSL_get_peer_cert_chain(ossock->ossl_ssl);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (chain) {</span><br><span style="color: hsl(0, 100%, 40%);">-- ssl_update_remote_cert_chain_info(ssock->pool,</span><br><span style="color: hsl(0, 100%, 40%);">-- &ssock->remote_cert_info,</span><br><span style="color: hsl(0, 100%, 40%);">-- chain, PJ_TRUE);</span><br><span style="color: hsl(0, 100%, 40%);">-- } else {</span><br><span style="color: hsl(0, 100%, 40%);">-- ssock->remote_cert_info.raw_chain.cnt = 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%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- </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/patches/0031-transport-regression-fix.patch b/third-party/pjproject/patches/0031-transport-regression-fix.patch</span><br><span>new file mode 100644</span><br><span>index 0000000..fdd8836</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/pjproject/patches/0031-transport-regression-fix.patch</span><br><span>@@ -0,0 +1,187 @@</span><br><span style="color: hsl(120, 100%, 40%);">+From 9c6108ca392d5e0392e7fb5d2ffde85e3c44ce55 Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(120, 100%, 40%);">+From: George Joseph <gjoseph@digium.com></span><br><span style="color: hsl(120, 100%, 40%);">+Date: Wed, 9 Oct 2019 07:50:32 -0600</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: [PATCH 31/31] transport regression fix</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.c | 73 +++++++++++++++++++++++++++------</span><br><span style="color: hsl(120, 100%, 40%);">+ 1 file changed, 61 insertions(+), 12 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.c b/pjsip/src/pjsip/sip_transport.c</span><br><span style="color: hsl(120, 100%, 40%);">+index 65ac823d4..da6b70e50 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%);">+@@ -50,6 +50,24 @@ static const char *addr_string(const pj_sockaddr_t *addr)</span><br><span style="color: hsl(120, 100%, 40%);">+ str, sizeof(str));</span><br><span style="color: hsl(120, 100%, 40%);">+ return str;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">++static const char* print_tpsel_info(const pjsip_tpselector *sel)</span><br><span style="color: hsl(120, 100%, 40%);">++{</span><br><span style="color: hsl(120, 100%, 40%);">++ static char tpsel_info_buf[80];</span><br><span style="color: hsl(120, 100%, 40%);">++ if (!sel) return "(null)";</span><br><span style="color: hsl(120, 100%, 40%);">++ if (sel->type==PJSIP_TPSELECTOR_LISTENER)</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_ansi_snprintf(tpsel_info_buf, sizeof(tpsel_info_buf),</span><br><span style="color: hsl(120, 100%, 40%);">++ "listener[%s], reuse=%d", sel->u.listener->obj_name,</span><br><span style="color: hsl(120, 100%, 40%);">++ !sel->disable_connection_reuse);</span><br><span style="color: hsl(120, 100%, 40%);">++ else if (sel->type==PJSIP_TPSELECTOR_TRANSPORT)</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_ansi_snprintf(tpsel_info_buf, sizeof(tpsel_info_buf),</span><br><span style="color: hsl(120, 100%, 40%);">++ "transport[%s], reuse=%d", sel->u.transport->info,</span><br><span style="color: hsl(120, 100%, 40%);">++ !sel->disable_connection_reuse);</span><br><span style="color: hsl(120, 100%, 40%);">++ else</span><br><span style="color: hsl(120, 100%, 40%);">++ pj_ansi_snprintf(tpsel_info_buf, sizeof(tpsel_info_buf),</span><br><span style="color: hsl(120, 100%, 40%);">++ "unknown[%p], reuse=%d", sel->u.ptr,</span><br><span style="color: hsl(120, 100%, 40%);">++ !sel->disable_connection_reuse);</span><br><span style="color: hsl(120, 100%, 40%);">++ return tpsel_info_buf;</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%);">+ # define TRACE_(x)</span><br><span style="color: hsl(120, 100%, 40%);">+ #endif</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1210,10 +1228,14 @@ PJ_DEF(pj_status_t) pjsip_transport_register( pjsip_tpmgr *mgr,</span><br><span style="color: hsl(120, 100%, 40%);">+ * new transport to the list.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_list_push_back(tp_ref, tp_add);</span><br><span style="color: hsl(120, 100%, 40%);">++ TRACE_((THIS_FILE, "Remote address already registered, "</span><br><span style="color: hsl(120, 100%, 40%);">++ "appended the transport to the list"));</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Transport list not found, add it to the hash table. */</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_hash_set_np(mgr->table, &tp->key, key_len, hval, tp_add->tp_buf,</span><br><span style="color: hsl(120, 100%, 40%);">+ tp_add);</span><br><span style="color: hsl(120, 100%, 40%);">++ TRACE_((THIS_FILE, "Remote address not registered, "</span><br><span style="color: hsl(120, 100%, 40%);">++ "added the transport to the hash"));</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%);">+ /* Add ref transport group lock, if any */</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -1283,6 +1305,13 @@ static pj_status_t destroy_transport( pjsip_tpmgr *mgr,</span><br><span style="color: hsl(120, 100%, 40%);">+ /* The transport list has multiple entry. */</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_hash_set_np(mgr->table, &tp_next->tp->key, key_len,</span><br><span style="color: hsl(120, 100%, 40%);">+ hval, tp_next->tp_buf, tp_next);</span><br><span style="color: hsl(120, 100%, 40%);">++ TRACE_((THIS_FILE, "Hash entry updated after "</span><br><span style="color: hsl(120, 100%, 40%);">++ "transport %d being destroyed",</span><br><span style="color: hsl(120, 100%, 40%);">++ tp->obj_name));</span><br><span style="color: hsl(120, 100%, 40%);">++ } else {</span><br><span style="color: hsl(120, 100%, 40%);">++ TRACE_((THIS_FILE, "Hash entry deleted after "</span><br><span style="color: hsl(120, 100%, 40%);">++ "transport %d being destroyed",</span><br><span style="color: hsl(120, 100%, 40%);">++ tp->obj_name));</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%);">+@@ -1294,6 +1323,14 @@ 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%);">+ tp_iter = tp_iter->next;</span><br><span style="color: hsl(120, 100%, 40%);">+ } while (tp_iter != tp_ref);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ if (tp_iter->tp != tp) {</span><br><span style="color: hsl(120, 100%, 40%);">++ PJ_LOG(3, (THIS_FILE, "Warning: transport %s being destroyed is "</span><br><span style="color: hsl(120, 100%, 40%);">++ "not registered", tp->obj_name));</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_LOG(3, (THIS_FILE, "Warning: transport %s being destroyed is "</span><br><span style="color: hsl(120, 100%, 40%);">++ "not found in the hash table", tp->obj_name));</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(mgr->lock);</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -2159,6 +2196,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport(pjsip_tpmgr *mgr,</span><br><span style="color: hsl(120, 100%, 40%);">+ NULL, tp);</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%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ * pjsip_tpmgr_acquire_transport2()</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -2176,8 +2214,9 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_tpfactory *factory;</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%);">+- TRACE_((THIS_FILE,"Acquiring transport type=%s, remote=%s:%d",</span><br><span style="color: hsl(120, 100%, 40%);">++ TRACE_((THIS_FILE,"Acquiring transport type=%s, sel=%s remote=%s:%d",</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_transport_get_type_name(type),</span><br><span style="color: hsl(120, 100%, 40%);">++ print_tpsel_info(sel),</span><br><span style="color: hsl(120, 100%, 40%);">+ addr_string(remote),</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_sockaddr_get_port(remote)));</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -2194,6 +2233,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,</span><br><span style="color: hsl(120, 100%, 40%);">+ /* See if the transport is (not) suitable */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (seltp->key.type != type) {</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_lock_release(mgr->lock);</span><br><span style="color: hsl(120, 100%, 40%);">++ TRACE_((THIS_FILE, "Transport type in tpsel not matched"));</span><br><span style="color: hsl(120, 100%, 40%);">+ return PJSIP_ETPNOTSUITABLE;</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%);">+@@ -2234,6 +2274,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (sel->u.listener->type != type) {</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_lock_release(mgr->lock);</span><br><span style="color: hsl(120, 100%, 40%);">++ TRACE_((THIS_FILE, "Listener type in tpsel not matched"));</span><br><span style="color: hsl(120, 100%, 40%);">+ return PJSIP_ETPNOTSUITABLE;</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%);">+@@ -2249,21 +2290,25 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,</span><br><span style="color: hsl(120, 100%, 40%);">+ tp_entry = (transport *)pj_hash_get(mgr->table, &key, key_len,</span><br><span style="color: hsl(120, 100%, 40%);">+ NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (tp_entry) {</span><br><span style="color: hsl(120, 100%, 40%);">+- if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER) {</span><br><span style="color: hsl(120, 100%, 40%);">+- transport *tp_iter = tp_entry;</span><br><span style="color: hsl(120, 100%, 40%);">+- do {</span><br><span style="color: hsl(120, 100%, 40%);">++ transport *tp_iter = tp_entry;</span><br><span style="color: hsl(120, 100%, 40%);">++ do {</span><br><span style="color: hsl(120, 100%, 40%);">++ /* Don't use transport being shutdown */</span><br><span style="color: hsl(120, 100%, 40%);">++ if (!tp_iter->tp->is_shutdown) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&</span><br><span style="color: hsl(120, 100%, 40%);">+- sel->u.listener &&</span><br><span style="color: hsl(120, 100%, 40%);">+- tp_iter->tp->factory == sel->u.listener)</span><br><span style="color: hsl(120, 100%, 40%);">++ sel->u.listener)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">++ /* Match listener if selector is set */</span><br><span style="color: hsl(120, 100%, 40%);">++ if (tp_iter->tp->factory == sel->u.listener) {</span><br><span style="color: hsl(120, 100%, 40%);">++ tp_ref = tp_iter->tp;</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%);">++ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ tp_ref = tp_iter->tp;</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%);">+- tp_iter = tp_iter->next;</span><br><span style="color: hsl(120, 100%, 40%);">+- } while (tp_iter != tp_entry);</span><br><span style="color: hsl(120, 100%, 40%);">+- } else {</span><br><span style="color: hsl(120, 100%, 40%);">+- tp_ref = tp_entry->tp;</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%);">++ tp_iter = tp_iter->next;</span><br><span style="color: hsl(120, 100%, 40%);">++ } while (tp_iter != tp_entry);</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%);">+@@ -2276,7 +2321,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Ignore address for loop transports. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (type == PJSIP_TRANSPORT_LOOP ||</span><br><span style="color: hsl(120, 100%, 40%);">+- type == PJSIP_TRANSPORT_LOOP_DGRAM)</span><br><span style="color: hsl(120, 100%, 40%);">++ type == PJSIP_TRANSPORT_LOOP_DGRAM)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_sockaddr *addr = &key.rem_addr;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -2315,6 +2360,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,</span><br><span style="color: hsl(120, 100%, 40%);">+ * 'duplicate' of the existing transport (same type & remote addr,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but different factory).</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">++ TRACE_((THIS_FILE, "Transport found but from different listener"));</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%);">+ if (tp_ref!=NULL && !tp_ref->is_shutdown) {</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -2347,10 +2393,13 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,</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%);">+ /* Verify that the listener type matches the destination type */</span><br><span style="color: hsl(120, 100%, 40%);">++ /* Already checked above. */</span><br><span style="color: hsl(120, 100%, 40%);">++ /*</span><br><span style="color: hsl(120, 100%, 40%);">+ if (sel->u.listener->type != type) {</span><br><span style="color: hsl(120, 100%, 40%);">+ pj_lock_release(mgr->lock);</span><br><span style="color: hsl(120, 100%, 40%);">+ return PJSIP_ETPNOTSUITABLE;</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%);">+ /* We'll use this listener to create transport */</span><br><span style="color: hsl(120, 100%, 40%);">+ factory = sel->u.listener;</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>diff --git a/third-party/pjproject/patches/0032-Revert-Re-2147-misc-Fix-failed-pjsip-test-transport_.patch b/third-party/pjproject/patches/0032-Revert-Re-2147-misc-Fix-failed-pjsip-test-transport_.patch</span><br><span>deleted file mode 100644</span><br><span>index df8f817..0000000</span><br><span>--- a/third-party/pjproject/patches/0032-Revert-Re-2147-misc-Fix-failed-pjsip-test-transport_.patch</span><br><span>+++ /dev/null</span><br><span>@@ -1,64 +0,0 @@</span><br><span style="color: hsl(0, 100%, 40%);">-From 17cd744e19cd332a219a512770fa6e18453044ba Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(0, 100%, 40%);">-From: George Joseph <gjoseph@digium.com></span><br><span style="color: hsl(0, 100%, 40%);">-Date: Tue, 24 Sep 2019 06:45:25 -0600</span><br><span style="color: hsl(0, 100%, 40%);">-Subject: [PATCH 32/33] Revert "Re #2147 (misc): Fix failed pjsip-test</span><br><span style="color: hsl(0, 100%, 40%);">- (transport_loop_test) caused by r6002."</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-This reverts commit 342148f5bcf3a6b0029ce834b8567c2cd691b15b.</span><br><span>----</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/pjsip/sip_transport.c | 12 +++++-------</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/pjsip/sip_transport_loop.c | 2 +-</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/test/transport_loop_test.c | 1 -</span><br><span style="color: hsl(0, 100%, 40%);">- 3 files changed, 6 insertions(+), 9 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.c b/pjsip/src/pjsip/sip_transport.c</span><br><span style="color: hsl(0, 100%, 40%);">-index 65ac823d4..d63823a98 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%);">-@@ -1222,13 +1222,11 @@ PJ_DEF(pj_status_t) pjsip_transport_register( pjsip_tpmgr *mgr,</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%);">-- tp->obj_name,</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport_get_type_name(tp->key.type),</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_sockaddr_has_addr(&tp->key.rem_addr)?</span><br><span style="color: hsl(0, 100%, 40%);">-- addr_string(&tp->key.rem_addr):"",</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_sockaddr_has_addr(&tp->key.rem_addr)?</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_sockaddr_get_port(&tp->key.rem_addr):0));</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%);">-+ tp->obj_name,</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_transport_get_type_name(tp->key.type),</span><br><span style="color: hsl(0, 100%, 40%);">-+ addr_string(&tp->key.rem_addr),</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_sockaddr_get_port(&tp->key.rem_addr)));</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%);">-diff --git a/pjsip/src/pjsip/sip_transport_loop.c b/pjsip/src/pjsip/sip_transport_loop.c</span><br><span style="color: hsl(0, 100%, 40%);">-index 37e20e69b..24e1a5f69 100644</span><br><span>---- a/pjsip/src/pjsip/sip_transport_loop.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/src/pjsip/sip_transport_loop.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -376,7 +376,7 @@ PJ_DEF(pj_status_t) pjsip_loop_start( pjsip_endpoint *endpt,</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%);">- loop->base.key.type = PJSIP_TRANSPORT_LOOP_DGRAM;</span><br><span style="color: hsl(0, 100%, 40%);">-- //loop->base.key.rem_addr.addr.sa_family = pj_AF_INET();</span><br><span style="color: hsl(0, 100%, 40%);">-+ loop->base.key.rem_addr.addr.sa_family = pj_AF_INET();</span><br><span style="color: hsl(0, 100%, 40%);">- loop->base.type_name = "LOOP-DGRAM";</span><br><span style="color: hsl(0, 100%, 40%);">- loop->base.info = "LOOP-DGRAM";</span><br><span style="color: hsl(0, 100%, 40%);">- loop->base.flag = PJSIP_TRANSPORT_DATAGRAM;</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/src/test/transport_loop_test.c b/pjsip/src/test/transport_loop_test.c</span><br><span style="color: hsl(0, 100%, 40%);">-index 5f2f03904..efa2ea116 100644</span><br><span>---- a/pjsip/src/test/transport_loop_test.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/src/test/transport_loop_test.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -36,7 +36,6 @@ static int datagram_loop_test()</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- PJ_LOG(3,(THIS_FILE, "testing datagram loop transport"));</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- pj_sockaddr_in_init(&addr, NULL, 0);</span><br><span style="color: hsl(0, 100%, 40%);">- /* Test acquire transport. */</span><br><span style="color: hsl(0, 100%, 40%);">- status = pjsip_endpt_acquire_transport( endpt, PJSIP_TRANSPORT_LOOP_DGRAM,</span><br><span style="color: hsl(0, 100%, 40%);">- &addr, sizeof(addr), NULL, &loop);</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/patches/0033-Revert-Close-1019-Support-for-multiple-listeners.patch b/third-party/pjproject/patches/0033-Revert-Close-1019-Support-for-multiple-listeners.patch</span><br><span>deleted file mode 100644</span><br><span>index 8a8f99a..0000000</span><br><span>--- a/third-party/pjproject/patches/0033-Revert-Close-1019-Support-for-multiple-listeners.patch</span><br><span>+++ /dev/null</span><br><span>@@ -1,1094 +0,0 @@</span><br><span style="color: hsl(0, 100%, 40%);">-From a720f3ffd538d3baef6f8daf78d9d320a4a5c0a0 Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(0, 100%, 40%);">-From: George Joseph <gjoseph@digium.com></span><br><span style="color: hsl(0, 100%, 40%);">-Date: Tue, 24 Sep 2019 06:45:59 -0600</span><br><span style="color: hsl(0, 100%, 40%);">-Subject: [PATCH 33/33] Revert "Close #1019: Support for multiple listeners."</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-This reverts commit 142dd0e96edad15b6b9554636043b5255d5d8adf.</span><br><span>----</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/include/pjsip/sip_config.h | 10 +-</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/pjsip/sip_transport.c | 318 ++++++++++-----------------</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/pjsip/sip_transport_loop.c | 2 +-</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/test/test.c | 3 -</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/test/transport_tcp_test.c | 193 ++++------------</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip/src/test/transport_udp_test.c | 148 +++++--------</span><br><span style="color: hsl(0, 100%, 40%);">- 6 files changed, 215 insertions(+), 459 deletions(-)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/include/pjsip/sip_config.h b/pjsip/include/pjsip/sip_config.h</span><br><span style="color: hsl(0, 100%, 40%);">-index 585aa722c..904df24e1 100644</span><br><span>---- a/pjsip/include/pjsip/sip_config.h</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/include/pjsip/sip_config.h</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -433,7 +433,7 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void)</span><br><span style="color: hsl(0, 100%, 40%);">- * This option can also be controlled at run-time by the</span><br><span style="color: hsl(0, 100%, 40%);">- * \a accept_multiple_sdp_answers setting in pjsip_cfg_t.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">-- * Default is PJ_TRUE.</span><br><span style="color: hsl(0, 100%, 40%);">-+ * Default is PJ_FALSE.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- #ifndef PJSIP_ACCEPT_MULTIPLE_SDP_ANSWERS</span><br><span style="color: hsl(0, 100%, 40%);">- # define PJSIP_ACCEPT_MULTIPLE_SDP_ANSWERS PJ_TRUE</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -692,7 +692,7 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void)</span><br><span style="color: hsl(0, 100%, 40%);">- * will be used as the default value for the "reuse_addr" field in the</span><br><span style="color: hsl(0, 100%, 40%);">- * pjsip_tcp_transport_cfg structure.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">-- * Default is 0 on Windows and 1 on non-Windows.</span><br><span style="color: hsl(0, 100%, 40%);">-+ * Default is FALSE on Windows and TRUE on non-Windows.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * @see PJSIP_TLS_TRANSPORT_REUSEADDR</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -718,7 +718,7 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void)</span><br><span style="color: hsl(0, 100%, 40%);">- * pj_getipinterface()/pj_gethostip(), but the address will not be</span><br><span style="color: hsl(0, 100%, 40%);">- * able to accept connections. </span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">-- * Default is 0 (listener will be created).</span><br><span style="color: hsl(0, 100%, 40%);">-+ * Default is FALSE (listener will be created).</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- #ifndef PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER</span><br><span style="color: hsl(0, 100%, 40%);">- # define PJSIP_TCP_TRANSPORT_DONT_CREATE_LISTENER 0</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -738,7 +738,7 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void)</span><br><span style="color: hsl(0, 100%, 40%);">- * pj_getipinterface()/pj_gethostip(), but the address will not be</span><br><span style="color: hsl(0, 100%, 40%);">- * able to accept connections.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">-- * Default is 0 (listener will be created).</span><br><span style="color: hsl(0, 100%, 40%);">-+ * Default is FALSE (listener will be created).</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- #ifndef PJSIP_TLS_TRANSPORT_DONT_CREATE_LISTENER</span><br><span style="color: hsl(0, 100%, 40%);">- # define PJSIP_TLS_TRANSPORT_DONT_CREATE_LISTENER 0</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -881,7 +881,7 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void)</span><br><span style="color: hsl(0, 100%, 40%);">- /**</span><br><span style="color: hsl(0, 100%, 40%);">- * Specify whether TLS listener should use SO_REUSEADDR option.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">-- * Default is 0 on Windows and 1 on non-Windows.</span><br><span style="color: hsl(0, 100%, 40%);">-+ * Default is FALSE on Windows and TRUE on non-Windows.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * @see PJSIP_TCP_TRANSPORT_REUSEADDR</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 d63823a98..54e8be380 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%);">-@@ -54,25 +54,6 @@ static const char *addr_string(const pj_sockaddr_t *addr)</span><br><span style="color: hsl(0, 100%, 40%);">- # define TRACE_(x)</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%);">--/* Specify the initial size of the transport manager's pool. */</span><br><span style="color: hsl(0, 100%, 40%);">--#ifndef TPMGR_POOL_INIT_SIZE</span><br><span style="color: hsl(0, 100%, 40%);">--# define TPMGR_POOL_INIT_SIZE 64</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%);">--/* Specify the increment size of the transport manager's pool. */</span><br><span style="color: hsl(0, 100%, 40%);">--#ifndef TPMGR_POOL_INC_SIZE</span><br><span style="color: hsl(0, 100%, 40%);">-- #define TPMGR_POOL_INC_SIZE 64</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%);">--/* Specify transport entry allocation count. When registering a new transport,</span><br><span style="color: hsl(0, 100%, 40%);">-- * a new entry will be picked from a free list. This setting will determine</span><br><span style="color: hsl(0, 100%, 40%);">-- * the size of the free list size. If all entry is used, then the same number</span><br><span style="color: hsl(0, 100%, 40%);">-- * of entry will be allocated.</span><br><span style="color: hsl(0, 100%, 40%);">-- */</span><br><span style="color: hsl(0, 100%, 40%);">--#ifndef PJSIP_TRANSPORT_ENTRY_ALLOC_CNT</span><br><span style="color: hsl(0, 100%, 40%);">--# define PJSIP_TRANSPORT_ENTRY_ALLOC_CNT 16</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%);">- /* Prototype. */</span><br><span style="color: hsl(0, 100%, 40%);">- static pj_status_t mod_on_tx_msg(pjsip_tx_data *tdata);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-@@ -100,7 +81,6 @@ static pjsip_module mod_msg_print =</span><br><span style="color: hsl(0, 100%, 40%);">- typedef struct transport</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">- PJ_DECL_LIST_MEMBER(struct transport);</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_hash_entry_buf tp_buf;</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_transport *tp;</span><br><span style="color: hsl(0, 100%, 40%);">- } transport;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-@@ -113,7 +93,6 @@ struct pjsip_tpmgr</span><br><span style="color: hsl(0, 100%, 40%);">- pj_lock_t *lock;</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_endpoint *endpt;</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_tpfactory factory_list;</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_pool_t *pool;</span><br><span style="color: hsl(0, 100%, 40%);">- #if defined(PJ_DEBUG) && PJ_DEBUG!=0</span><br><span style="color: hsl(0, 100%, 40%);">- pj_atomic_t *tdata_counter;</span><br><span style="color: hsl(0, 100%, 40%);">- #endif</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -126,9 +105,12 @@ struct pjsip_tpmgr</span><br><span style="color: hsl(0, 100%, 40%);">- * is destroyed.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_tx_data tdata_list;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- /* List of free transport entry. */</span><br><span style="color: hsl(0, 100%, 40%);">-- transport tp_entry_freelist;</span><br><span style="color: hsl(0, 100%, 40%);">-+ </span><br><span style="color: hsl(0, 100%, 40%);">-+ /* List of transports which are NOT stored in the hash table, so</span><br><span style="color: hsl(0, 100%, 40%);">-+ * that it can be properly cleaned up when transport manager</span><br><span style="color: hsl(0, 100%, 40%);">-+ * is destroyed.</span><br><span style="color: hsl(0, 100%, 40%);">-+ */</span><br><span style="color: hsl(0, 100%, 40%);">-+ transport tp_list;</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%);">-@@ -1042,18 +1024,18 @@ static pj_bool_t is_transport_valid(pjsip_transport *tp, pjsip_tpmgr *tpmgr,</span><br><span style="color: hsl(0, 100%, 40%);">- const pjsip_transport_key *key,</span><br><span style="color: hsl(0, 100%, 40%);">- int key_len)</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">-- transport *tp_entry;</span><br><span style="color: hsl(0, 100%, 40%);">-+ transport *tp_iter;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- tp_entry = (transport *)pj_hash_get(tpmgr->table, key, key_len, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (tp_entry != NULL) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (pj_hash_get(tpmgr->table, key, key_len, NULL) == (void*)tp) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ return PJ_TRUE;</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%);">-- transport *tp_iter = tp_entry;</span><br><span style="color: hsl(0, 100%, 40%);">-- do {</span><br><span style="color: hsl(0, 100%, 40%);">-- if (tp_iter->tp == tp) {</span><br><span style="color: hsl(0, 100%, 40%);">-- return PJ_TRUE;</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_iter = tp_iter->next;</span><br><span style="color: hsl(0, 100%, 40%);">-- } while (tp_iter != tp_entry);</span><br><span style="color: hsl(0, 100%, 40%);">-+ tp_iter = tpmgr->tp_list.next;</span><br><span style="color: hsl(0, 100%, 40%);">-+ while (tp_iter != &tpmgr->tp_list) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (tp_iter->tp == tp) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ return PJ_TRUE;</span><br><span style="color: hsl(0, 100%, 40%);">-+ }</span><br><span style="color: hsl(0, 100%, 40%);">-+ tp_iter = tp_iter->next;</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_FALSE;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1153,9 +1135,8 @@ PJ_DEF(pj_status_t) pjsip_transport_dec_ref( pjsip_transport *tp )</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%);">-+ 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%);">- </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%);">-@@ -1169,8 +1150,7 @@ PJ_DEF(pj_status_t) pjsip_transport_register( pjsip_tpmgr *mgr,</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">- int key_len;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_uint32_t hval;</span><br><span style="color: hsl(0, 100%, 40%);">-- transport *tp_ref = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-- transport *tp_add = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-+ void *entry;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /* Init. */</span><br><span style="color: hsl(0, 100%, 40%);">- tp->tpmgr = mgr;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1178,43 +1158,31 @@ PJ_DEF(pj_status_t) pjsip_transport_register( pjsip_tpmgr *mgr,</span><br><span style="color: hsl(0, 100%, 40%);">- tp->idle_timer.user_data = tp;</span><br><span style="color: hsl(0, 100%, 40%);">- tp->idle_timer.cb = &transport_idle_callback;</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%);">- * Register to hash table (see Trac ticket #42).</span><br><span style="color: hsl(0, 100%, 40%);">- */</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%);">- pj_lock_acquire(mgr->lock);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-+ /* If entry already occupied, unregister previous entry */</span><br><span style="color: hsl(0, 100%, 40%);">- hval = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_ref = (transport *)pj_hash_get(mgr->table, &tp->key, key_len, &hval);</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Get an empty entry from the freelist. */</span><br><span style="color: hsl(0, 100%, 40%);">-- if (pj_list_empty(&mgr->tp_entry_freelist)) {</span><br><span style="color: hsl(0, 100%, 40%);">-- unsigned i = 0;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- TRACE_((THIS_FILE, "Transport list is full, allocate new entry"));</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Allocate new entry for the freelist. */</span><br><span style="color: hsl(0, 100%, 40%);">-- for (; i < PJSIP_TRANSPORT_ENTRY_ALLOC_CNT; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_add = PJ_POOL_ZALLOC_T(mgr->pool, transport);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (!tp_add)</span><br><span style="color: hsl(0, 100%, 40%);">-- return PJ_ENOMEM;</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_list_init(tp_add);</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_list_push_back(&mgr->tp_entry_freelist, tp_add);</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-+ entry = pj_hash_get(mgr->table, &tp->key, key_len, &hval);</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (entry != NULL) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ transport *tp_ref;</span><br><span style="color: hsl(0, 100%, 40%);">-+ </span><br><span style="color: hsl(0, 100%, 40%);">-+ tp_ref = PJ_POOL_ZALLOC_T(((pjsip_transport *)entry)->pool, transport);</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%);">-+ * Add transport to the list before removing it from the hash table.</span><br><span style="color: hsl(0, 100%, 40%);">-+ * See ticket #1774 for more details.</span><br><span style="color: hsl(0, 100%, 40%);">-+ */</span><br><span style="color: hsl(0, 100%, 40%);">-+ tp_ref->tp = (pjsip_transport *)entry;</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_list_push_back(&mgr->tp_list, tp_ref);</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_hash_set(NULL, mgr->table, &tp->key, key_len, hval, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_add = mgr->tp_entry_freelist.next;</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_add->tp = tp;</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_list_erase(tp_add);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- if (tp_ref) {</span><br><span style="color: hsl(0, 100%, 40%);">-- /* There'a already a transport list from the hash table. Add the </span><br><span style="color: hsl(0, 100%, 40%);">-- * new transport to the list.</span><br><span style="color: hsl(0, 100%, 40%);">-- */</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_list_push_back(tp_ref, tp_add);</span><br><span style="color: hsl(0, 100%, 40%);">-- } else {</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Transport list not found, add it to the hash table. */</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_hash_set_np(mgr->table, &tp->key, key_len, hval, tp_add->tp_buf,</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_add);</span><br><span style="color: hsl(0, 100%, 40%);">-- }</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%);">-@@ -1261,46 +1229,26 @@ static pj_status_t destroy_transport( pjsip_tpmgr *mgr,</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%);">- hval = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- entry = pj_hash_get(mgr->table, &tp->key, key_len, &hval);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (entry) {</span><br><span style="color: hsl(0, 100%, 40%);">-- transport *tp_ref = (transport *)entry;</span><br><span style="color: hsl(0, 100%, 40%);">-- transport *tp_iter = tp_ref;</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Search the matching entry from the transport list. */</span><br><span style="color: hsl(0, 100%, 40%);">-- do {</span><br><span style="color: hsl(0, 100%, 40%);">-- if (tp_iter->tp == tp) {</span><br><span style="color: hsl(0, 100%, 40%);">-- transport *tp_next = tp_iter->next;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Update hash table :</span><br><span style="color: hsl(0, 100%, 40%);">-- * - transport list only contain single element, or</span><br><span style="color: hsl(0, 100%, 40%);">-- * - the entry is the first element of the transport list.</span><br><span style="color: hsl(0, 100%, 40%);">-- */</span><br><span style="color: hsl(0, 100%, 40%);">-- if (tp_iter == tp_ref) {</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_hash_set(NULL, mgr->table, &tp->key, key_len, hval,</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 (tp_ref->next != tp_ref) {</span><br><span style="color: hsl(0, 100%, 40%);">-- /* The transport list has multiple entry. */</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_hash_set_np(mgr->table, &tp_next->tp->key, key_len,</span><br><span style="color: hsl(0, 100%, 40%);">-- hval, tp_next->tp_buf, tp_next);</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%);">-- pj_list_erase(tp_iter);</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Put back to the transport freelist. */</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_list_push_back(&mgr->tp_entry_freelist, tp_iter);</span><br><span style="color: hsl(0, 100%, 40%);">--</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%);">-- tp_iter = tp_iter->next;</span><br><span style="color: hsl(0, 100%, 40%);">-- } while (tp_iter != tp_ref);</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (entry == (void*)tp) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_hash_set(NULL, mgr->table, &tp->key, key_len, hval, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-+ } else {</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* If not found in hash table, remove from the tranport list. */</span><br><span style="color: hsl(0, 100%, 40%);">-+ transport *tp_iter = mgr->tp_list.next;</span><br><span style="color: hsl(0, 100%, 40%);">-+ while (tp_iter != &mgr->tp_list) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (tp_iter->tp == tp) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_list_erase(tp_iter);</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%);">-+ tp_iter = tp_iter->next;</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%);">- 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%);">-+ 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%);">- </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%);">-@@ -1414,9 +1362,13 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_register_tpfactory( pjsip_tpmgr *mgr,</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- pj_lock_acquire(mgr->lock);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- /* Check that no same factory has been registered. */</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Check that no factory with the same type has been registered. */</span><br><span style="color: hsl(0, 100%, 40%);">- status = PJ_SUCCESS;</span><br><span style="color: hsl(0, 100%, 40%);">- for (p=mgr->factory_list.next; p!=&mgr->factory_list; p=p->next) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (p->type == tpf->type) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ status = PJSIP_ETYPEEXISTS;</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%);">- if (p == tpf) {</span><br><span style="color: hsl(0, 100%, 40%);">- status = PJ_EEXISTS;</span><br><span style="color: hsl(0, 100%, 40%);">- break;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1491,8 +1443,6 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_create( pj_pool_t *pool,</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_tpmgr *mgr;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_status_t status;</span><br><span style="color: hsl(0, 100%, 40%);">-- unsigned i = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_pool_t *mgr_pool;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- PJ_ASSERT_RETURN(pool && endpt && rx_cb && p_mgr, PJ_EINVAL);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1502,42 +1452,24 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_create( pj_pool_t *pool,</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%);">- /* Create and initialize transport manager. */</span><br><span style="color: hsl(0, 100%, 40%);">-- mgr_pool = pjsip_endpt_create_pool(endpt, "tpmgr",</span><br><span style="color: hsl(0, 100%, 40%);">-- TPMGR_POOL_INIT_SIZE,</span><br><span style="color: hsl(0, 100%, 40%);">-- TPMGR_POOL_INC_SIZE);</span><br><span style="color: hsl(0, 100%, 40%);">-- mgr = PJ_POOL_ZALLOC_T(mgr_pool, pjsip_tpmgr);</span><br><span style="color: hsl(0, 100%, 40%);">-+ mgr = PJ_POOL_ZALLOC_T(pool, pjsip_tpmgr);</span><br><span style="color: hsl(0, 100%, 40%);">- mgr->endpt = endpt;</span><br><span style="color: hsl(0, 100%, 40%);">- mgr->on_rx_msg = rx_cb;</span><br><span style="color: hsl(0, 100%, 40%);">- mgr->on_tx_msg = tx_cb;</span><br><span style="color: hsl(0, 100%, 40%);">-- mgr->pool = mgr_pool;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- if (!mgr->pool)</span><br><span style="color: hsl(0, 100%, 40%);">-- return PJ_ENOMEM;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">- pj_list_init(&mgr->factory_list);</span><br><span style="color: hsl(0, 100%, 40%);">- pj_list_init(&mgr->tdata_list);</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_list_init(&mgr->tp_entry_freelist);</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_list_init(&mgr->tp_list);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- mgr->table = pj_hash_create(mgr->pool, PJSIP_TPMGR_HTABLE_SIZE);</span><br><span style="color: hsl(0, 100%, 40%);">-+ mgr->table = pj_hash_create(pool, PJSIP_TPMGR_HTABLE_SIZE);</span><br><span style="color: hsl(0, 100%, 40%);">- if (!mgr->table)</span><br><span style="color: hsl(0, 100%, 40%);">- return PJ_ENOMEM;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- status = pj_lock_create_recursive_mutex(mgr->pool, "tmgr%p", &mgr->lock);</span><br><span style="color: hsl(0, 100%, 40%);">-+ status = pj_lock_create_recursive_mutex(pool, "tmgr%p", &mgr->lock);</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%);">-- for (; i < PJSIP_TRANSPORT_ENTRY_ALLOC_CNT; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- transport *tp_add = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_add = PJ_POOL_ZALLOC_T(mgr->pool, transport);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (!tp_add)</span><br><span style="color: hsl(0, 100%, 40%);">-- return PJ_ENOMEM;</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_list_init(tp_add);</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_list_push_back(&mgr->tp_entry_freelist, tp_add);</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 defined(PJ_DEBUG) && PJ_DEBUG!=0</span><br><span style="color: hsl(0, 100%, 40%);">-- status = pj_atomic_create(mgr->pool, 0, &mgr->tdata_counter);</span><br><span style="color: hsl(0, 100%, 40%);">-+ status = pj_atomic_create(pool, 0, &mgr->tdata_counter);</span><br><span style="color: hsl(0, 100%, 40%);">- if (status != PJ_SUCCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">- pj_lock_destroy(mgr->lock);</span><br><span style="color: hsl(0, 100%, 40%);">- return status;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1765,16 +1697,15 @@ PJ_DEF(unsigned) pjsip_tpmgr_get_transport_count(pjsip_tpmgr *mgr)</span><br><span style="color: hsl(0, 100%, 40%);">- pj_hash_iterator_t itr_val;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_hash_iterator_t *itr;</span><br><span style="color: hsl(0, 100%, 40%);">- int nr_of_transports = 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_lock_acquire(mgr->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%);">- itr = pj_hash_first(mgr->table, &itr_val);</span><br><span style="color: hsl(0, 100%, 40%);">- while (itr) {</span><br><span style="color: hsl(0, 100%, 40%);">-- transport *tp_entry = (transport *)pj_hash_this(mgr->table, itr);</span><br><span style="color: hsl(0, 100%, 40%);">-- nr_of_transports += pj_list_size(tp_entry);</span><br><span style="color: hsl(0, 100%, 40%);">-+ nr_of_transports++;</span><br><span style="color: hsl(0, 100%, 40%);">- itr = pj_hash_next(mgr->table, itr);</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%);">- pj_lock_release(mgr->lock);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- return nr_of_transports;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1791,7 +1722,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_destroy( pjsip_tpmgr *mgr )</span><br><span style="color: hsl(0, 100%, 40%);">- pj_hash_iterator_t *itr;</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_tpfactory *factory;</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_endpoint *endpt = mgr->endpt;</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_LOG(5, (THIS_FILE, "Destroying transport manager"));</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- pj_lock_acquire(mgr->lock);</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1799,21 +1730,39 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_destroy( pjsip_tpmgr *mgr )</span><br><span style="color: hsl(0, 100%, 40%);">- /*</span><br><span style="color: hsl(0, 100%, 40%);">- * Destroy all transports in the hash table.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-- for (itr = pj_hash_first(mgr->table, &itr_val); itr;</span><br><span style="color: hsl(0, 100%, 40%);">-- itr = pj_hash_first(mgr->table, &itr_val))</span><br><span style="color: hsl(0, 100%, 40%);">-- {</span><br><span style="color: hsl(0, 100%, 40%);">-- transport *tp_ref;</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_ref = pj_hash_this(mgr->table, itr);</span><br><span style="color: hsl(0, 100%, 40%);">-- destroy_transport(mgr, tp_ref->tp);</span><br><span style="color: hsl(0, 100%, 40%);">-+ itr = pj_hash_first(mgr->table, &itr_val);</span><br><span style="color: hsl(0, 100%, 40%);">-+ while (itr != NULL) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_hash_iterator_t *next;</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_transport *transport;</span><br><span style="color: hsl(0, 100%, 40%);">-+ </span><br><span style="color: hsl(0, 100%, 40%);">-+ transport = (pjsip_transport*) pj_hash_this(mgr->table, itr);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ next = pj_hash_next(mgr->table, itr);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ destroy_transport(mgr, transport);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ itr = next;</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%);">-+ * Destroy transports in the list.</span><br><span style="color: hsl(0, 100%, 40%);">-+ */</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (!pj_list_empty(&mgr->tp_list)) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ transport *tp_iter = mgr->tp_list.next;</span><br><span style="color: hsl(0, 100%, 40%);">-+ while (tp_iter != &mgr->tp_list) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ transport *next = tp_iter->next;</span><br><span style="color: hsl(0, 100%, 40%);">-+ destroy_transport(mgr, tp_iter->tp);</span><br><span style="color: hsl(0, 100%, 40%);">-+ tp_iter = next;</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%);">- * Destroy all factories/listeners.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- factory = mgr->factory_list.next;</span><br><span style="color: hsl(0, 100%, 40%);">- while (factory != &mgr->factory_list) {</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_tpfactory *next = factory->next;</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%);">- factory->destroy(factory);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- factory = next;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -1857,10 +1806,6 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_destroy( pjsip_tpmgr *mgr )</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_endpt_unregister_module(endpt, &mod_msg_print);</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 (mgr->pool) {</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_endpt_release_pool( mgr->endpt, mgr->pool );</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%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-@@ -2221,9 +2166,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_transport_key key;</span><br><span style="color: hsl(0, 100%, 40%);">- int key_len;</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport *tp_ref = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-- transport *tp_entry = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_transport *transport = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /* If listener is specified, verify that the listener type matches</span><br><span style="color: hsl(0, 100%, 40%);">- * the destination type.</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -2244,28 +2187,11 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,</span><br><span style="color: hsl(0, 100%, 40%);">- key.type = type;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_memcpy(&key.rem_addr, remote, addr_len);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- tp_entry = (transport *)pj_hash_get(mgr->table, &key, key_len,</span><br><span style="color: hsl(0, 100%, 40%);">-- NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (tp_entry) {</span><br><span style="color: hsl(0, 100%, 40%);">-- if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER) {</span><br><span style="color: hsl(0, 100%, 40%);">-- transport *tp_iter = tp_entry;</span><br><span style="color: hsl(0, 100%, 40%);">-- do {</span><br><span style="color: hsl(0, 100%, 40%);">-- if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&</span><br><span style="color: hsl(0, 100%, 40%);">-- sel->u.listener &&</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_iter->tp->factory == sel->u.listener)</span><br><span style="color: hsl(0, 100%, 40%);">-- {</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_ref = tp_iter->tp;</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%);">-- tp_iter = tp_iter->next;</span><br><span style="color: hsl(0, 100%, 40%);">-- } while (tp_iter != tp_entry);</span><br><span style="color: hsl(0, 100%, 40%);">-- } else {</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_ref = tp_entry->tp;</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%);">-+ transport = (pjsip_transport*)</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_hash_get(mgr->table, &key, key_len, NULL);</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 (tp_ref == NULL &&</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (transport == NULL &&</span><br><span style="color: hsl(0, 100%, 40%);">- (!sel || sel->disable_connection_reuse == PJ_FALSE))</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">- unsigned flag = pjsip_transport_get_flag_from_type(type);</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -2280,11 +2206,8 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- pj_bzero(addr, addr_len);</span><br><span style="color: hsl(0, 100%, 40%);">- key_len = sizeof(key.type) + addr_len;</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_entry = (transport *) pj_hash_get(mgr->table, &key,</span><br><span style="color: hsl(0, 100%, 40%);">-- key_len, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (tp_entry) {</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_ref = tp_entry->tp;</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-+ transport = (pjsip_transport*) </span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_hash_get(mgr->table, &key, key_len, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- /* For datagram transports, try lookup with zero address.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -2296,34 +2219,31 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,</span><br><span style="color: hsl(0, 100%, 40%);">- addr->addr.sa_family = remote_addr->addr.sa_family;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- key_len = sizeof(key.type) + addr_len;</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_entry = (transport *) pj_hash_get(mgr->table, &key,</span><br><span style="color: hsl(0, 100%, 40%);">-- key_len, NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (tp_entry) {</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_ref = tp_entry->tp;</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-+ transport = (pjsip_transport*)</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_hash_get(mgr->table, &key, key_len, NULL);</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 transport is found and listener is specified, verify listener */</span><br><span style="color: hsl(0, 100%, 40%);">- else if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&</span><br><span style="color: hsl(0, 100%, 40%);">-- sel->u.listener && tp_ref->factory != sel->u.listener)</span><br><span style="color: hsl(0, 100%, 40%);">-+ sel->u.listener && transport->factory != sel->u.listener)</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_ref = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-+ transport = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- /* This will cause a new transport to be created which will be a</span><br><span style="color: hsl(0, 100%, 40%);">- * 'duplicate' of the existing transport (same type & remote addr,</span><br><span style="color: hsl(0, 100%, 40%);">- * but different factory).</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 (tp_ref!=NULL && !tp_ref->is_shutdown) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (transport!=NULL && !transport->is_shutdown) {</span><br><span style="color: hsl(0, 100%, 40%);">- /*</span><br><span style="color: hsl(0, 100%, 40%);">- * Transport found!</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport_add_ref(tp_ref);</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_transport_add_ref(transport);</span><br><span style="color: hsl(0, 100%, 40%);">- pj_lock_release(mgr->lock);</span><br><span style="color: hsl(0, 100%, 40%);">-- *tp = tp_ref;</span><br><span style="color: hsl(0, 100%, 40%);">-+ *tp = transport;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- TRACE_((THIS_FILE, "Transport %s acquired", tp_ref->obj_name));</span><br><span style="color: hsl(0, 100%, 40%);">-+ TRACE_((THIS_FILE, "Transport %s acquired", transport->obj_name));</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%);">-@@ -2385,15 +2305,15 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,</span><br><span style="color: hsl(0, 100%, 40%);">- /* Request factory to create transport. */</span><br><span style="color: hsl(0, 100%, 40%);">- if (factory->create_transport2) {</span><br><span style="color: hsl(0, 100%, 40%);">- status = factory->create_transport2(factory, mgr, mgr->endpt,</span><br><span style="color: hsl(0, 100%, 40%);">-- (const pj_sockaddr*) remote,</span><br><span style="color: hsl(0, 100%, 40%);">-+ (const pj_sockaddr*) remote, </span><br><span style="color: hsl(0, 100%, 40%);">- addr_len, tdata, tp);</span><br><span style="color: hsl(0, 100%, 40%);">- } else {</span><br><span style="color: hsl(0, 100%, 40%);">- status = factory->create_transport(factory, mgr, mgr->endpt,</span><br><span style="color: hsl(0, 100%, 40%);">-- (const pj_sockaddr*) remote,</span><br><span style="color: hsl(0, 100%, 40%);">-+ (const pj_sockaddr*) remote, </span><br><span style="color: hsl(0, 100%, 40%);">- addr_len, tp);</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%);">-- PJ_ASSERT_ON_FAIL(tp!=NULL,</span><br><span style="color: hsl(0, 100%, 40%);">-+ PJ_ASSERT_ON_FAIL(tp!=NULL, </span><br><span style="color: hsl(0, 100%, 40%);">- {pj_lock_release(mgr->lock); return PJ_EBUG;});</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_transport_add_ref(*tp);</span><br><span style="color: hsl(0, 100%, 40%);">- (*tp)->factory = factory;</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -2436,25 +2356,15 @@ PJ_DEF(void) pjsip_tpmgr_dump_transports(pjsip_tpmgr *mgr)</span><br><span style="color: hsl(0, 100%, 40%);">- PJ_LOG(3, (THIS_FILE, " Dumping transports:"));</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- do {</span><br><span style="color: hsl(0, 100%, 40%);">-- transport *tp_entry = (transport *) pj_hash_this(mgr->table, itr);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (tp_entry) {</span><br><span style="color: hsl(0, 100%, 40%);">-- transport *tp_iter = tp_entry;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- do {</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport *tp_ref = tp_iter->tp;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- PJ_LOG(3, (THIS_FILE, " %s %s%s%s%s(refcnt=%d%s)",</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_ref->obj_name,</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_ref->info,</span><br><span style="color: hsl(0, 100%, 40%);">-- (tp_ref->factory)?" listener[":"",</span><br><span style="color: hsl(0, 100%, 40%);">-- (tp_ref->factory)?tp_ref->factory->obj_name:"",</span><br><span style="color: hsl(0, 100%, 40%);">-- (tp_ref->factory)?"]":"",</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_atomic_get(tp_ref->ref_cnt),</span><br><span style="color: hsl(0, 100%, 40%);">-- (tp_ref->idle_timer.id ? " [idle]" : "")));</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_iter = tp_iter->next;</span><br><span style="color: hsl(0, 100%, 40%);">-- } while (tp_iter != tp_entry);</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_transport *t = (pjsip_transport*) </span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_hash_this(mgr->table, itr);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ PJ_LOG(3, (THIS_FILE, " %s %s (refcnt=%d%s)", </span><br><span style="color: hsl(0, 100%, 40%);">-+ t->obj_name,</span><br><span style="color: hsl(0, 100%, 40%);">-+ t->info,</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_atomic_get(t->ref_cnt),</span><br><span style="color: hsl(0, 100%, 40%);">-+ (t->idle_timer.id ? " [idle]" : "")));</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- itr = pj_hash_next(mgr->table, itr);</span><br><span style="color: hsl(0, 100%, 40%);">- } while (itr);</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_loop.c b/pjsip/src/pjsip/sip_transport_loop.c</span><br><span style="color: hsl(0, 100%, 40%);">-index 24e1a5f69..5cbe26a97 100644</span><br><span>---- a/pjsip/src/pjsip/sip_transport_loop.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/src/pjsip/sip_transport_loop.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -376,7 +376,7 @@ PJ_DEF(pj_status_t) pjsip_loop_start( pjsip_endpoint *endpt,</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%);">- loop->base.key.type = PJSIP_TRANSPORT_LOOP_DGRAM;</span><br><span style="color: hsl(0, 100%, 40%);">-- loop->base.key.rem_addr.addr.sa_family = pj_AF_INET();</span><br><span style="color: hsl(0, 100%, 40%);">-+ //loop->base.key.rem_addr.sa_family = pj_AF_INET();</span><br><span style="color: hsl(0, 100%, 40%);">- loop->base.type_name = "LOOP-DGRAM";</span><br><span style="color: hsl(0, 100%, 40%);">- loop->base.info = "LOOP-DGRAM";</span><br><span style="color: hsl(0, 100%, 40%);">- loop->base.flag = PJSIP_TRANSPORT_DATAGRAM;</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/src/test/test.c b/pjsip/src/test/test.c</span><br><span style="color: hsl(0, 100%, 40%);">-index 3898d45ff..0361e6178 100644</span><br><span>---- a/pjsip/src/test/test.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/src/test/test.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -379,9 +379,6 @@ int test_main(void)</span><br><span style="color: hsl(0, 100%, 40%);">- on_return:</span><br><span style="color: hsl(0, 100%, 40%);">- flush_events(500);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- /* Show additional info on the log. e.g: not released memory pool. */</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_log_set_level(4);</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">- /* Dumping memory pool usage */</span><br><span style="color: hsl(0, 100%, 40%);">- PJ_LOG(3,(THIS_FILE, "Peak memory size=%u MB",</span><br><span style="color: hsl(0, 100%, 40%);">- caching_pool.peak_used_size / 1000000));</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/src/test/transport_tcp_test.c b/pjsip/src/test/transport_tcp_test.c</span><br><span style="color: hsl(0, 100%, 40%);">-index b10455664..3ff5f8ff4 100644</span><br><span>---- a/pjsip/src/test/transport_tcp_test.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/src/test/transport_tcp_test.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -29,154 +29,64 @@</span><br><span style="color: hsl(0, 100%, 40%);">- * TCP transport test.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- #if PJ_HAS_TCP</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">--static pj_status_t multi_listener_test(pjsip_tpfactory *factory[],</span><br><span style="color: hsl(0, 100%, 40%);">-- unsigned num_factory,</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport *tp[],</span><br><span style="color: hsl(0, 100%, 40%);">-- unsigned *num_tp)</span><br><span style="color: hsl(0, 100%, 40%);">-+int transport_tcp_test(void)</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_status_t status;</span><br><span style="color: hsl(0, 100%, 40%);">-- unsigned i = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_str_t s;</span><br><span style="color: hsl(0, 100%, 40%);">-+ enum { SEND_RECV_LOOP = 8 };</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_tpfactory *tpfactory;</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_transport *tcp;</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_tpfactory *tpfactory = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr_in rem_addr;</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_tpselector tp_sel;</span><br><span style="color: hsl(0, 100%, 40%);">-- unsigned ntp = 0;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- for (;i<num_factory;++i)</span><br><span style="color: hsl(0, 100%, 40%);">-- {</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Start TCP listener on arbitrary port. */</span><br><span style="color: hsl(0, 100%, 40%);">-- status = pjsip_tcp_transport_start(endpt, NULL, 1, &tpfactory);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (status != PJ_SUCCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">-- app_perror(" Error: unable to start TCP transport", status);</span><br><span style="color: hsl(0, 100%, 40%);">-- return -10;</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_status_t status;</span><br><span style="color: hsl(0, 100%, 40%);">-+ char url[PJSIP_MAX_URL_SIZE];</span><br><span style="color: hsl(0, 100%, 40%);">-+ char addr[PJ_INET_ADDRSTRLEN];</span><br><span style="color: hsl(0, 100%, 40%);">-+ int rtt[SEND_RECV_LOOP], min_rtt;</span><br><span style="color: hsl(0, 100%, 40%);">-+ int i, pkt_lost;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- factory[i] = tpfactory;</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Start TCP listener on arbitrary port. */</span><br><span style="color: hsl(0, 100%, 40%);">-+ status = pjsip_tcp_transport_start(endpt, NULL, 1, &tpfactory);</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (status != PJ_SUCCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ app_perror(" Error: unable to start TCP transport", status);</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -10;</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%);">-- /* Get the last listener address */</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Get the listener address */</span><br><span style="color: hsl(0, 100%, 40%);">- status = pj_sockaddr_in_init(&rem_addr, &tpfactory->addr_name.host,</span><br><span style="color: hsl(0, 100%, 40%);">- (pj_uint16_t)tpfactory->addr_name.port);</span><br><span style="color: hsl(0, 100%, 40%);">- if (status != PJ_SUCCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">- app_perror(" Error: possibly invalid TCP address name", status);</span><br><span style="color: hsl(0, 100%, 40%);">-- return -11;</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -14;</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%);">-- /* Acquire transport without selector. */</span><br><span style="color: hsl(0, 100%, 40%);">-- status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_TCP,</span><br><span style="color: hsl(0, 100%, 40%);">-- &rem_addr, sizeof(rem_addr),</span><br><span style="color: hsl(0, 100%, 40%);">-- NULL, &tcp);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (status != PJ_SUCCESS || tcp == NULL) {</span><br><span style="color: hsl(0, 100%, 40%);">-- app_perror(" Error: unable to acquire TCP transport", status);</span><br><span style="color: hsl(0, 100%, 40%);">-- return -12;</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-- tp[ntp++] = tcp;</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_ansi_sprintf(url, "sip:alice@%s:%d;transport=tcp",</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_inet_ntop2(pj_AF_INET(), &rem_addr.sin_addr, addr,</span><br><span style="color: hsl(0, 100%, 40%);">-+ sizeof(addr)),</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_ntohs(rem_addr.sin_port));</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- /* After pjsip_endpt_acquire_transport, TCP transport must have</span><br><span style="color: hsl(0, 100%, 40%);">-- * reference counter 1.</span><br><span style="color: hsl(0, 100%, 40%);">-- */</span><br><span style="color: hsl(0, 100%, 40%);">-- if (pj_atomic_get(tcp->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -13;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- /* Acquire with the same remote address, should return the same tp. */</span><br><span style="color: hsl(0, 100%, 40%);">-- status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_TCP,</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Acquire one TCP transport. */</span><br><span style="color: hsl(0, 100%, 40%);">-+ status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_TCP, </span><br><span style="color: hsl(0, 100%, 40%);">- &rem_addr, sizeof(rem_addr),</span><br><span style="color: hsl(0, 100%, 40%);">- NULL, &tcp);</span><br><span style="color: hsl(0, 100%, 40%);">- if (status != PJ_SUCCESS || tcp == NULL) {</span><br><span style="color: hsl(0, 100%, 40%);">- app_perror(" Error: unable to acquire TCP transport", status);</span><br><span style="color: hsl(0, 100%, 40%);">-- return -14;</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%);">-- /* Should return existing transport. */</span><br><span style="color: hsl(0, 100%, 40%);">-- if (tp[ntp-1] != tcp) {</span><br><span style="color: hsl(0, 100%, 40%);">-- return -15;</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -17;</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%);">-- /* Using the same TCP transport, it must have reference counter 2.</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* After pjsip_endpt_acquire_transport, TCP transport must have</span><br><span style="color: hsl(0, 100%, 40%);">-+ * reference counter 1. </span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-- if (pj_atomic_get(tcp->ref_cnt) != 2)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -16;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Decrease the reference. */</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport_dec_ref(tcp);</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (pj_atomic_get(tcp->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -20;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /* Test basic transport attributes */</span><br><span style="color: hsl(0, 100%, 40%);">- status = generic_transport_test(tcp);</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%);">- /* Check again that reference counter is 1. */</span><br><span style="color: hsl(0, 100%, 40%);">- if (pj_atomic_get(tcp->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -17;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Acquire transport test with selector. */</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_bzero(&tp_sel, sizeof(tp_sel));</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_sel.type = PJSIP_TPSELECTOR_LISTENER;</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_sel.u.listener = factory[num_factory/2];</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_sockaddr_in_init(&rem_addr, pj_cstr(&s, "1.1.1.1"), 80);</span><br><span style="color: hsl(0, 100%, 40%);">-- status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_TCP,</span><br><span style="color: hsl(0, 100%, 40%);">-- &rem_addr, sizeof(rem_addr),</span><br><span style="color: hsl(0, 100%, 40%);">-- &tp_sel, &tcp);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (status != PJ_SUCCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">-- app_perror(" Error: unable to acquire TCP transport", status);</span><br><span style="color: hsl(0, 100%, 40%);">-- return -18;</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%);">-- /* The transport should have the same factory set on the selector. */</span><br><span style="color: hsl(0, 100%, 40%);">-- if (tcp->factory != factory[num_factory/2])</span><br><span style="color: hsl(0, 100%, 40%);">-- return -19;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- /* The transport should be newly created. */</span><br><span style="color: hsl(0, 100%, 40%);">-- for (i = 0; i < ntp; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- if (tp[i] == tcp) {</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%);">-- if (i != ntp)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -20;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- tp[ntp++] = tcp;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- for (i = 0; i<ntp; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- if (pj_atomic_get(tp[i]->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -21;</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-- *num_tp = ntp;</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%);">--int transport_tcp_test(void)</span><br><span style="color: hsl(0, 100%, 40%);">--{</span><br><span style="color: hsl(0, 100%, 40%);">-- enum { SEND_RECV_LOOP = 8 };</span><br><span style="color: hsl(0, 100%, 40%);">-- enum { NUM_LISTENER = 4 };</span><br><span style="color: hsl(0, 100%, 40%);">-- enum { NUM_TP = 8 };</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_tpfactory *tpfactory[NUM_LISTENER];</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport *tcp[NUM_TP];</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_sockaddr_in rem_addr;</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_status_t status;</span><br><span style="color: hsl(0, 100%, 40%);">-- char url[PJSIP_MAX_URL_SIZE];</span><br><span style="color: hsl(0, 100%, 40%);">-- char addr[PJ_INET_ADDRSTRLEN];</span><br><span style="color: hsl(0, 100%, 40%);">-- int rtt[SEND_RECV_LOOP], min_rtt;</span><br><span style="color: hsl(0, 100%, 40%);">-- int pkt_lost;</span><br><span style="color: hsl(0, 100%, 40%);">-- unsigned i;</span><br><span style="color: hsl(0, 100%, 40%);">-- unsigned num_listener = NUM_LISTENER;</span><br><span style="color: hsl(0, 100%, 40%);">-- unsigned num_tp = NUM_TP;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- status = multi_listener_test(tpfactory, num_listener, tcp, &num_tp);</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%);">-- /* Get the last listener address */</span><br><span style="color: hsl(0, 100%, 40%);">-- status = pj_sockaddr_in_init(&rem_addr, &tpfactory[0]->addr_name.host,</span><br><span style="color: hsl(0, 100%, 40%);">-- (pj_uint16_t)tpfactory[0]->addr_name.port);</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_ansi_sprintf(url, "sip:alice@%s:%d;transport=tcp",</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_inet_ntop2(pj_AF_INET(), &rem_addr.sin_addr, addr,</span><br><span style="color: hsl(0, 100%, 40%);">-- sizeof(addr)),</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_ntohs(rem_addr.sin_port));</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -40;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /* Load test */</span><br><span style="color: hsl(0, 100%, 40%);">- if (transport_load_test(url) != 0)</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -184,13 +94,10 @@ int transport_tcp_test(void)</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /* Basic transport's send/receive loopback test. */</span><br><span style="color: hsl(0, 100%, 40%);">- for (i=0; i<SEND_RECV_LOOP; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- status = transport_send_recv_test(PJSIP_TRANSPORT_TCP, tcp[0], url,</span><br><span style="color: hsl(0, 100%, 40%);">-- &rtt[i]);</span><br><span style="color: hsl(0, 100%, 40%);">-+ status = transport_send_recv_test(PJSIP_TRANSPORT_TCP, tcp, url, &rtt[i]);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- if (status != 0) {</span><br><span style="color: hsl(0, 100%, 40%);">-- for (i = 0; i < num_tp ; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport_dec_ref(tcp[i]);</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_transport_dec_ref(tcp);</span><br><span style="color: hsl(0, 100%, 40%);">- flush_events(500);</span><br><span style="color: hsl(0, 100%, 40%);">- return -72;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -208,11 +115,9 @@ int transport_tcp_test(void)</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%);">- /* Multi-threaded round-trip test. */</span><br><span style="color: hsl(0, 100%, 40%);">-- status = transport_rt_test(PJSIP_TRANSPORT_TCP, tcp[0], url, &pkt_lost);</span><br><span style="color: hsl(0, 100%, 40%);">-+ status = transport_rt_test(PJSIP_TRANSPORT_TCP, tcp, url, &pkt_lost);</span><br><span style="color: hsl(0, 100%, 40%);">- if (status != 0) {</span><br><span style="color: hsl(0, 100%, 40%);">-- for (i = 0; i < num_tp ; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport_dec_ref(tcp[i]);</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_transport_dec_ref(tcp);</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%);">-@@ -220,28 +125,22 @@ int transport_tcp_test(void)</span><br><span style="color: hsl(0, 100%, 40%);">- PJ_LOG(3,(THIS_FILE, " note: %d packet(s) was lost", pkt_lost));</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /* Check again that reference counter is still 1. */</span><br><span style="color: hsl(0, 100%, 40%);">-- for (i = 0; i < num_tp; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- if (pj_atomic_get(tcp[i]->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -80;</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (pj_atomic_get(tcp->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -80;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- for (i = 0; i < num_tp; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Destroy this transport. */</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport_dec_ref(tcp[i]);</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Destroy this transport. */</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_transport_dec_ref(tcp);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- /* Force destroy this transport. */</span><br><span style="color: hsl(0, 100%, 40%);">-- status = pjsip_transport_destroy(tcp[i]);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (status != PJ_SUCCESS)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -90;</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Force destroy this transport. */</span><br><span style="color: hsl(0, 100%, 40%);">-+ status = pjsip_transport_destroy(tcp);</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (status != PJ_SUCCESS)</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -90;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- for (i = 0; i < num_listener; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Unregister factory */</span><br><span style="color: hsl(0, 100%, 40%);">-- status = pjsip_tpmgr_unregister_tpfactory(pjsip_endpt_get_tpmgr(endpt),</span><br><span style="color: hsl(0, 100%, 40%);">-- tpfactory[i]);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (status != PJ_SUCCESS)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -95;</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Unregister factory */</span><br><span style="color: hsl(0, 100%, 40%);">-+ status = pjsip_tpmgr_unregister_tpfactory(pjsip_endpt_get_tpmgr(endpt), </span><br><span style="color: hsl(0, 100%, 40%);">-+ tpfactory);</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (status != PJ_SUCCESS)</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -95;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /* Flush events. */</span><br><span style="color: hsl(0, 100%, 40%);">- PJ_LOG(3,(THIS_FILE, " Flushing events, 1 second..."));</span><br><span style="color: hsl(0, 100%, 40%);">-diff --git a/pjsip/src/test/transport_udp_test.c b/pjsip/src/test/transport_udp_test.c</span><br><span style="color: hsl(0, 100%, 40%);">-index 579c7f071..bc0831a38 100644</span><br><span>---- a/pjsip/src/test/transport_udp_test.c</span><br><span style="color: hsl(0, 100%, 40%);">-+++ b/pjsip/src/test/transport_udp_test.c</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -24,88 +24,6 @@</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- #define THIS_FILE "transport_udp_test.c"</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">--static pj_status_t multi_transport_test(pjsip_transport *tp[], unsigned num_tp)</span><br><span style="color: hsl(0, 100%, 40%);">--{</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_status_t status;</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_uint16_t i = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_str_t s;</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport *udp_tp;</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_sockaddr_in rem_addr; </span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_tpselector tp_sel;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- for (;i<num_tp;++i)</span><br><span style="color: hsl(0, 100%, 40%);">-- {</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_sockaddr_in addr;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_sockaddr_in_init(&addr, NULL, TEST_UDP_PORT+i);</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Start UDP transport. */</span><br><span style="color: hsl(0, 100%, 40%);">-- status = pjsip_udp_transport_start( endpt, &addr, NULL, 1, &udp_tp);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (status != PJ_SUCCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">-- app_perror(" Error: unable to start UDP transport", status);</span><br><span style="color: hsl(0, 100%, 40%);">-- return -110;</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%);">-- /* UDP transport must have initial reference counter set to 1. */</span><br><span style="color: hsl(0, 100%, 40%);">-- if (pj_atomic_get(udp_tp->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -120;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Test basic transport attributes */</span><br><span style="color: hsl(0, 100%, 40%);">-- status = generic_transport_test(udp_tp);</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%);">-- tp[i] = udp_tp;</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%);">-- for (i = 0; i < num_tp; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- udp_tp = tp[i];</span><br><span style="color: hsl(0, 100%, 40%);">-- if (pj_atomic_get(udp_tp->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -130;</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%);">-- /* Acquire transport test without selector. */</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_sockaddr_in_init(&rem_addr, pj_cstr(&s, "1.1.1.1"), 80);</span><br><span style="color: hsl(0, 100%, 40%);">-- status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_UDP,</span><br><span style="color: hsl(0, 100%, 40%);">-- &rem_addr, sizeof(rem_addr),</span><br><span style="color: hsl(0, 100%, 40%);">-- NULL, &udp_tp);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (status != PJ_SUCCESS)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -140;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- for (i = 0; i < num_tp; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- if (udp_tp == tp[i]) {</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%);">-- if (i == num_tp)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -150;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport_dec_ref(udp_tp);</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- if (pj_atomic_get(udp_tp->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -160;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- /* Acquire transport test with selector. */</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_bzero(&tp_sel, sizeof(tp_sel));</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_sel.type = PJSIP_TPSELECTOR_TRANSPORT;</span><br><span style="color: hsl(0, 100%, 40%);">-- tp_sel.u.transport = tp[num_tp-1];</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_sockaddr_in_init(&rem_addr, pj_cstr(&s, "1.1.1.1"), 80);</span><br><span style="color: hsl(0, 100%, 40%);">-- status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_UDP,</span><br><span style="color: hsl(0, 100%, 40%);">-- &rem_addr, sizeof(rem_addr),</span><br><span style="color: hsl(0, 100%, 40%);">-- &tp_sel, &udp_tp);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (status != PJ_SUCCESS)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -170;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- if (udp_tp != tp[num_tp-1])</span><br><span style="color: hsl(0, 100%, 40%);">-- return -180;</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport_dec_ref(udp_tp);</span><br><span style="color: hsl(0, 100%, 40%);">--</span><br><span style="color: hsl(0, 100%, 40%);">-- if (pj_atomic_get(udp_tp->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -190;</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%);">- /*</span><br><span style="color: hsl(0, 100%, 40%);">- * UDP transport test.</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -113,22 +31,56 @@ static pj_status_t multi_transport_test(pjsip_transport *tp[], unsigned num_tp)</span><br><span style="color: hsl(0, 100%, 40%);">- int transport_udp_test(void)</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">- enum { SEND_RECV_LOOP = 8 };</span><br><span style="color: hsl(0, 100%, 40%);">-- enum { NUM_TP = 4 };</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport *tp[NUM_TP], *udp_tp;</span><br><span style="color: hsl(0, 100%, 40%);">-- pj_sockaddr_in rem_addr;</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_transport *udp_tp, *tp;</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_sockaddr_in addr, rem_addr;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_str_t s;</span><br><span style="color: hsl(0, 100%, 40%);">- pj_status_t status;</span><br><span style="color: hsl(0, 100%, 40%);">- int rtt[SEND_RECV_LOOP], min_rtt;</span><br><span style="color: hsl(0, 100%, 40%);">- int i, pkt_lost;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- status = multi_transport_test(&tp[0], NUM_TP);</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_sockaddr_in_init(&addr, NULL, TEST_UDP_PORT);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Start UDP transport. */</span><br><span style="color: hsl(0, 100%, 40%);">-+ status = pjsip_udp_transport_start( endpt, &addr, NULL, 1, &udp_tp);</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (status != PJ_SUCCESS) {</span><br><span style="color: hsl(0, 100%, 40%);">-+ app_perror(" Error: unable to start UDP transport", status);</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -10;</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%);">-+ /* UDP transport must have initial reference counter set to 1. */</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (pj_atomic_get(udp_tp->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -20;</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Test basic transport attributes */</span><br><span style="color: hsl(0, 100%, 40%);">-+ status = generic_transport_test(udp_tp);</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%);">-+ /* Test that transport manager is returning the correct</span><br><span style="color: hsl(0, 100%, 40%);">-+ * transport.</span><br><span style="color: hsl(0, 100%, 40%);">-+ */</span><br><span style="color: hsl(0, 100%, 40%);">-+ pj_sockaddr_in_init(&rem_addr, pj_cstr(&s, "1.1.1.1"), 80);</span><br><span style="color: hsl(0, 100%, 40%);">-+ status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_UDP, </span><br><span style="color: hsl(0, 100%, 40%);">-+ &rem_addr, sizeof(rem_addr),</span><br><span style="color: hsl(0, 100%, 40%);">-+ NULL, &tp);</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (status != PJ_SUCCESS)</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -50;</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (tp != udp_tp)</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -60;</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* pjsip_endpt_acquire_transport() adds reference, so we need</span><br><span style="color: hsl(0, 100%, 40%);">-+ * to decrement it.</span><br><span style="color: hsl(0, 100%, 40%);">-+ */</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_transport_dec_ref(tp);</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Check again that reference counter is 1. */</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (pj_atomic_get(udp_tp->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -70;</span><br><span style="color: hsl(0, 100%, 40%);">-+</span><br><span style="color: hsl(0, 100%, 40%);">- /* Basic transport's send/receive loopback test. */</span><br><span style="color: hsl(0, 100%, 40%);">- pj_sockaddr_in_init(&rem_addr, pj_cstr(&s, "127.0.0.1"), TEST_UDP_PORT);</span><br><span style="color: hsl(0, 100%, 40%);">- for (i=0; i<SEND_RECV_LOOP; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- status = transport_send_recv_test(PJSIP_TRANSPORT_UDP, tp[0], </span><br><span style="color: hsl(0, 100%, 40%);">-+ status = transport_send_recv_test(PJSIP_TRANSPORT_UDP, tp, </span><br><span style="color: hsl(0, 100%, 40%);">- "sip:alice@127.0.0.1:"TEST_UDP_PORT_STR,</span><br><span style="color: hsl(0, 100%, 40%);">- &rtt[i]);</span><br><span style="color: hsl(0, 100%, 40%);">- if (status != 0)</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -146,7 +98,7 @@ int transport_udp_test(void)</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%);">- /* Multi-threaded round-trip test. */</span><br><span style="color: hsl(0, 100%, 40%);">-- status = transport_rt_test(PJSIP_TRANSPORT_UDP, tp[0], </span><br><span style="color: hsl(0, 100%, 40%);">-+ status = transport_rt_test(PJSIP_TRANSPORT_UDP, tp, </span><br><span style="color: hsl(0, 100%, 40%);">- "sip:alice@127.0.0.1:"TEST_UDP_PORT_STR, </span><br><span style="color: hsl(0, 100%, 40%);">- &pkt_lost);</span><br><span style="color: hsl(0, 100%, 40%);">- if (status != 0)</span><br><span style="color: hsl(0, 100%, 40%);">-@@ -155,19 +107,17 @@ int transport_udp_test(void)</span><br><span style="color: hsl(0, 100%, 40%);">- if (pkt_lost != 0)</span><br><span style="color: hsl(0, 100%, 40%);">- PJ_LOG(3,(THIS_FILE, " note: %d packet(s) was lost", pkt_lost));</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- for (i = 0; i < NUM_TP; ++i) {</span><br><span style="color: hsl(0, 100%, 40%);">-- udp_tp = tp[i];</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Check again that reference counter is 1. */</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (pj_atomic_get(udp_tp->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -80;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- /* Check again that reference counter is 1. */</span><br><span style="color: hsl(0, 100%, 40%);">-- if (pj_atomic_get(udp_tp->ref_cnt) != 1)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -80;</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Destroy this transport. */</span><br><span style="color: hsl(0, 100%, 40%);">-+ pjsip_transport_dec_ref(udp_tp);</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">-- /* Destroy this transport. */</span><br><span style="color: hsl(0, 100%, 40%);">-- pjsip_transport_dec_ref(udp_tp);</span><br><span style="color: hsl(0, 100%, 40%);">-- status = pjsip_transport_destroy(udp_tp);</span><br><span style="color: hsl(0, 100%, 40%);">-- if (status != PJ_SUCCESS)</span><br><span style="color: hsl(0, 100%, 40%);">-- return -90;</span><br><span style="color: hsl(0, 100%, 40%);">-- }</span><br><span style="color: hsl(0, 100%, 40%);">-+ /* Force destroy this transport. */</span><br><span style="color: hsl(0, 100%, 40%);">-+ status = pjsip_transport_destroy(udp_tp);</span><br><span style="color: hsl(0, 100%, 40%);">-+ if (status != PJ_SUCCESS)</span><br><span style="color: hsl(0, 100%, 40%);">-+ return -90;</span><br><span style="color: hsl(0, 100%, 40%);">- </span><br><span style="color: hsl(0, 100%, 40%);">- /* Flush events. */</span><br><span style="color: hsl(0, 100%, 40%);">- PJ_LOG(3,(THIS_FILE, " Flushing events, 1 second..."));</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></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13039">change 13039</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/+/13039"/><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: I06f8507bea553d1a01b0b8874197d35b9d47ec4c </div>
<div style="display:none"> Gerrit-Change-Number: 13039 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Michael L. Young <elgueromexicano@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>