pjproject: bump to version 2.10

Sync with asterisk v16.13.0:
* update to v2.10
* update config_site.h settings
* sync patches

Signed-off-by: Andre Heider <a.heider@gmail.com>
This commit is contained in:
Andre Heider 2020-09-04 08:07:30 +02:00
parent 062878a672
commit a71a6666d2
14 changed files with 178 additions and 624 deletions

View file

@ -10,12 +10,14 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=pjproject
PKG_VERSION:=2.9
PKG_RELEASE:=4
PKG_VERSION:=2.10
PKG_RELEASE:=1
PKG_SOURCE:=pjproject-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://www.pjsip.org/release/$(PKG_VERSION)
PKG_HASH:=d185ef7855c8ec07191dde92f54b65a7a4b7a6f7bf8c46f7af35ceeb1da2a636
# download "vX.Y.tar.gz" as "pjproject-vX.Y.tar.gz"
PKG_SOURCE_URL_FILE:=$(PKG_VERSION).tar.gz
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_URL_FILE)
PKG_SOURCE_URL:=https://github.com/pjsip/$(PKG_NAME)/archive
PKG_HASH:=936a4c5b98601b52325463a397ddf11ab4106c6a7b04f8dc7cdd377efbb597de
PKG_INSTALL:=1
PKG_FIXUP:=autoreconf

View file

@ -58,13 +58,13 @@
+ Enabling it will result in SEGFAULTS when URIs containing escape sequences are encountered.
+*/
+#undef PJSIP_UNESCAPE_IN_PLACE
+#define PJSIP_MAX_PKT_LEN 32000
+#define PJSIP_MAX_PKT_LEN 65535
+
+#undef PJ_TODO
+#define PJ_TODO(x)
+
+/* Defaults too low for WebRTC */
+#define PJ_ICE_MAX_CAND 32
+#define PJ_ICE_MAX_CAND 64
+#define PJ_ICE_MAX_CHECKS (PJ_ICE_MAX_CAND * PJ_ICE_MAX_CAND)
+
+/* Increase limits to allow more formats */

View file

@ -1,6 +1,6 @@
--- a/build.mak.in
+++ b/build.mak.in
@@ -292,7 +292,6 @@ export APP_LDLIBS := $(PJSUA_LIB_LDLIB)
@@ -296,7 +296,6 @@ export APP_LDLIBS := $(PJSUA_LIB_LDLIB)
$(PJLIB_LDLIB) \
@LIBS@
export APP_LDXXLIBS := $(PJSUA2_LIB_LDLIB) \

View file

@ -13,7 +13,7 @@
Description: Multimedia communication library
--- a/build.mak.in
+++ b/build.mak.in
@@ -310,8 +310,7 @@ export PJ_LIBXX_FILES := $(APP_LIBXX_FIL
@@ -314,8 +314,7 @@ export PJ_LIBXX_FILES := $(APP_LIBXX_FIL
# And here are the variables to use if application is using the
# library from the install location (i.e. --prefix)
export PJ_INSTALL_DIR := @prefix@

View file

@ -1,157 +0,0 @@
From 85b28c475b5dfd3b01dafffd1d0b3dbb6f087829 Mon Sep 17 00:00:00 2001
From: George Joseph <gjoseph@digium.com>
Date: Thu, 27 Jun 2019 11:19:47 -0600
Subject: [PATCH] ssl_sock_ossl/sip_transport_tls: Add peer to error messages
Added peer address:port to error messages in ssl_sock_ossl.
Added peer hostname to error messages in sip_transport_tls.
---
pjlib/src/pj/ssl_sock_ossl.c | 22 +++++++++++++---------
pjsip/src/pjsip/sip_transport_tls.c | 17 +++++++++--------
2 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c
index b4ac5c15f..42db8fdbe 100644
--- a/pjlib/src/pj/ssl_sock_ossl.c
+++ b/pjlib/src/pj/ssl_sock_ossl.c
@@ -210,15 +210,19 @@ static char *SSLErrorString (int err)
}
}
-#define ERROR_LOG(msg, err) \
- PJ_LOG(2,("SSL", "%s (%s): Level: %d err: <%lu> <%s-%s-%s> len: %d", \
+#define ERROR_LOG(msg, err, ssock) \
+{ \
+ char buf[PJ_INET6_ADDRSTRLEN+10]; \
+ PJ_LOG(2,("SSL", "%s (%s): Level: %d err: <%lu> <%s-%s-%s> len: %d peer: %s", \
msg, action, level, err, \
(ERR_lib_error_string(err)? ERR_lib_error_string(err): "???"), \
(ERR_func_error_string(err)? ERR_func_error_string(err):"???"),\
(ERR_reason_error_string(err)? \
- ERR_reason_error_string(err): "???"), len));
+ ERR_reason_error_string(err): "???"), len, \
+ pj_sockaddr_print(&ssock->rem_addr, buf, sizeof(buf), 3))); \
+}
-static void SSLLogErrors(char * action, int ret, int ssl_err, int len)
+static void SSLLogErrors(char * action, int ret, int ssl_err, int len, pj_ssl_sock_t *ssock)
{
char *ssl_err_str = SSLErrorString(ssl_err);
@@ -233,7 +237,7 @@ static void SSLLogErrors(char * action, int ret, int ssl_err, int len)
if (err2) {
int level = 0;
while (err2) {
- ERROR_LOG("SSL_ERROR_SYSCALL", err2);
+ ERROR_LOG("SSL_ERROR_SYSCALL", err2, ssock);
level++;
err2 = ERR_get_error();
}
@@ -264,7 +268,7 @@ static void SSLLogErrors(char * action, int ret, int ssl_err, int len)
int level = 0;
while (err2) {
- ERROR_LOG("SSL_ERROR_SSL", err2);
+ ERROR_LOG("SSL_ERROR_SSL", err2, ssock);
level++;
err2 = ERR_get_error();
}
@@ -302,13 +306,13 @@ static pj_status_t STATUS_FROM_SSL_ERR(char *action, pj_ssl_sock_t *ssock,
int level = 0;
int len = 0; //dummy
- ERROR_LOG("STATUS_FROM_SSL_ERR", err);
+ ERROR_LOG("STATUS_FROM_SSL_ERR", err, ssock);
level++;
/* General SSL error, dig more from OpenSSL error queue */
if (err == SSL_ERROR_SSL) {
err = ERR_get_error();
- ERROR_LOG("STATUS_FROM_SSL_ERR", err);
+ ERROR_LOG("STATUS_FROM_SSL_ERR", err, ssock);
}
ssock->last_err = err;
@@ -326,7 +330,7 @@ static pj_status_t STATUS_FROM_SSL_ERR2(char *action, pj_ssl_sock_t *ssock,
}
/* Dig for more from OpenSSL error queue */
- SSLLogErrors(action, ret, err, len);
+ SSLLogErrors(action, ret, err, len, ssock);
ssock->last_err = ssl_err;
return GET_STATUS_FROM_SSL_ERR(ssl_err);
diff --git a/pjsip/src/pjsip/sip_transport_tls.c b/pjsip/src/pjsip/sip_transport_tls.c
index 38349aa7a..d40bc7ea3 100644
--- a/pjsip/src/pjsip/sip_transport_tls.c
+++ b/pjsip/src/pjsip/sip_transport_tls.c
@@ -173,9 +173,10 @@ static void wipe_buf(pj_str_t *buf);
static void tls_perror(const char *sender, const char *title,
- pj_status_t status)
+ pj_status_t status, pj_str_t *remote_name)
{
- PJ_PERROR(3,(sender, status, "%s: [code=%d]", title, status));
+ PJ_PERROR(3,(sender, status, "%s: [code=%d]%s%.*s", title, status,
+ remote_name ? " peer: " : "", remote_name ? remote_name->slen : 0, remote_name ? remote_name->ptr : ""));
}
@@ -730,7 +731,7 @@ PJ_DEF(pj_status_t) pjsip_tls_transport_restart(pjsip_tpfactory *factory,
status = pjsip_tls_transport_lis_start(factory, local, a_name);
if (status != PJ_SUCCESS) {
tls_perror(listener->factory.obj_name,
- "Unable to start listener after closing it", status);
+ "Unable to start listener after closing it", status, NULL);
return status;
}
@@ -739,7 +740,7 @@ PJ_DEF(pj_status_t) pjsip_tls_transport_restart(pjsip_tpfactory *factory,
&listener->factory);
if (status != PJ_SUCCESS) {
tls_perror(listener->factory.obj_name,
- "Unable to register the transport listener", status);
+ "Unable to register the transport listener", status, NULL);
listener->is_registered = PJ_FALSE;
} else {
@@ -1085,7 +1086,7 @@ static pj_status_t tls_start_read(struct tls_transport *tls)
PJSIP_POOL_RDATA_LEN,
PJSIP_POOL_RDATA_INC);
if (!pool) {
- tls_perror(tls->base.obj_name, "Unable to create pool", PJ_ENOMEM);
+ tls_perror(tls->base.obj_name, "Unable to create pool", PJ_ENOMEM, NULL);
return PJ_ENOMEM;
}
@@ -1772,7 +1773,7 @@ static pj_bool_t on_connect_complete(pj_ssl_sock_t *ssock,
/* Check connect() status */
if (status != PJ_SUCCESS) {
- tls_perror(tls->base.obj_name, "TLS connect() error", status);
+ tls_perror(tls->base.obj_name, "TLS connect() error", status, &tls->remote_name);
/* Cancel all delayed transmits */
while (!pj_list_empty(&tls->delayed_list)) {
@@ -1916,7 +1917,7 @@ static pj_bool_t on_connect_complete(pj_ssl_sock_t *ssock,
pjsip_transport_dec_ref(&tls->base);
if (is_shutdown) {
status = tls->close_reason;
- tls_perror(tls->base.obj_name, "TLS connect() error", status);
+ tls_perror(tls->base.obj_name, "TLS connect() error", status, &tls->remote_name);
/* Cancel all delayed transmits */
while (!pj_list_empty(&tls->delayed_list)) {
@@ -2015,7 +2016,7 @@ static void tls_keep_alive_timer(pj_timer_heap_t *th, pj_timer_entry *e)
if (status != PJ_SUCCESS && status != PJ_EPENDING) {
tls_perror(tls->base.obj_name,
- "Error sending keep-alive packet", status);
+ "Error sending keep-alive packet", status, &tls->remote_name);
tls_init_shutdown(tls, status);
return;
--
2.21.0

View file

@ -0,0 +1,37 @@
commit c3c1bf45cae2a35003aa16c267d59f97027f9c5e
Author: Kevin Harwell <kharwell@digium.com>
Date: Thu Jun 11 11:11:13 2020 -0500
sip_inv - fix invite session ref count crash
Ensure the session's ref count is only decremented under proper conditons.
For more details see the following issue report:
https://github.com/pjsip/pjproject/issues/2443
Patch supplied by sauwming
--- a/pjsip/src/pjsip-ua/sip_inv.c
+++ b/pjsip/src/pjsip-ua/sip_inv.c
@@ -323,9 +323,19 @@ static void inv_set_state(pjsip_inv_sess
(*mod_inv.cb.on_state_changed)(inv, e);
pjsip_inv_dec_ref(inv);
- /* Only decrement when previous state is not already DISCONNECTED */
+ /* The above callback may change the state, so we need to be careful here
+ * and only decrement inv under the following conditions:
+ * 1. If the state parameter is DISCONNECTED, and previous state is not
+ * already DISCONNECTED.
+ * This is to make sure that dec_ref() is not called more than once.
+ * 2. If current state is PJSIP_INV_STATE_DISCONNECTED.
+ * This is to make sure that dec_ref() is not called if user restarts
+ * inv within the callback. Note that this check must be last since
+ * inv may have already been destroyed.
+ */
if (state == PJSIP_INV_STATE_DISCONNECTED &&
- prev_state != PJSIP_INV_STATE_DISCONNECTED)
+ prev_state != PJSIP_INV_STATE_DISCONNECTED &&
+ inv->state == PJSIP_INV_STATE_DISCONNECTED)
{
pjsip_inv_dec_ref(inv);
}

View file

@ -1,53 +0,0 @@
Index: pjsip/include/pjsip/sip_config.h
===================================================================
--- a/pjsip/include/pjsip/sip_config.h (revision 6050)
+++ b/pjsip/include/pjsip/sip_config.h (working copy)
@@ -1190,6 +1190,20 @@
# define PJSIP_AUTH_CACHED_POOL_MAX_SIZE (20 * 1024)
#endif
+
+/**
+ * Specify whether the cnonce used for SIP authentication contain digits only.
+ * The "cnonce" value is setup using GUID generator, i.e:
+ * pj_create_unique_string(), and the GUID string may contain hyphen character
+ * ("-"). Some SIP servers do not like this GUID format, so this option will
+ * strip any hyphens from the GUID string.
+ *
+ * Default is 1 (cnonce will only contain digit characters).
+ */
+#ifndef PJSIP_AUTH_CNONCE_USE_DIGITS_ONLY
+# define PJSIP_AUTH_CNONCE_USE_DIGITS_ONLY 1
+#endif
+
/*****************************************************************************
* SIP Event framework and presence settings.
*/
Index: pjsip/src/pjsip/sip_auth_client.c
===================================================================
--- a/pjsip/src/pjsip/sip_auth_client.c (revision 6050)
+++ b/pjsip/src/pjsip/sip_auth_client.c (working copy)
@@ -396,7 +396,23 @@
/* Create cnonce */
pj_create_unique_string( cached_auth->pool, &cached_auth->cnonce );
+#if defined(PJSIP_AUTH_CNONCE_USE_DIGITS_ONLY) && \
+ PJSIP_AUTH_CNONCE_USE_DIGITS_ONLY!=0
+ if (pj_strchr(&cached_auth->cnonce, '-')) {
+ /* remove hyphen character. */
+ int w, r, len = pj_strlen(&cached_auth->cnonce);
+ char *s = cached_auth->cnonce.ptr;
+ w = r = 0;
+ for (; r < len; r++) {
+ if (s[r] != '-')
+ s[w++] = s[r];
+ }
+ s[w] = '\0';
+ cached_auth->cnonce.slen = w;
+ }
+#endif
+
/* Initialize nonce-count */
cached_auth->nc = 1;

View file

@ -0,0 +1,35 @@
commit 40dd48d10911f4ff9b8dfbf16428fbc9acc434ba
Author: Riza Sulistyo <trengginas@users.noreply.github.com>
Date: Thu Jul 9 17:47:24 2020 +0700
Modify timer_id check on cancel() (#2463)
* modify timer_id check on cancel().
* modification based on comments.
--- a/pjlib/include/pj/timer.h
+++ b/pjlib/include/pj/timer.h
@@ -120,7 +120,10 @@ typedef struct pj_timer_entry
/**
* Internal unique timer ID, which is assigned by the timer heap.
- * Application should not touch this ID.
+ * Positive values indicate that the timer entry is running,
+ * while -1 means that it's not. Any other value may indicate that it
+ * hasn't been properly initialised or is in a bad state.
+ * Application should not touch this ID.
*/
pj_timer_id_t _timer_id;
--- a/pjlib/src/pj/timer.c
+++ b/pjlib/src/pj/timer.c
@@ -535,7 +535,7 @@ static int cancel( pj_timer_heap_t *ht,
PJ_CHECK_STACK();
// Check to see if the timer_id is out of range
- if (entry->_timer_id < 0 || (pj_size_t)entry->_timer_id > ht->max_size) {
+ if (entry->_timer_id < 1 || (pj_size_t)entry->_timer_id >= ht->max_size) {
entry->_timer_id = -1;
return 0;
}

View file

@ -1,94 +0,0 @@
From 489281f29fc7b97143cf79154f22e5007adaba39 Mon Sep 17 00:00:00 2001
From: George Joseph <gjoseph@digium.com>
Date: Wed, 9 Oct 2019 07:49:44 -0600
Subject: [PATCH 30/31] ssl regression fix
---
pjlib/src/pj/ssl_sock_gtls.c | 6 ++++--
pjlib/src/pj/ssl_sock_imp_common.c | 4 ++++
pjlib/src/pj/ssl_sock_imp_common.h | 3 +++
pjlib/src/pj/ssl_sock_ossl.c | 9 +++++----
4 files changed, 16 insertions(+), 6 deletions(-)
--- a/pjlib/src/pj/ssl_sock_gtls.c
+++ b/pjlib/src/pj/ssl_sock_gtls.c
@@ -1050,7 +1050,8 @@ static void ssl_update_certs_info(pj_ssl
goto us_out;
tls_cert_get_info(ssock->pool, &ssock->local_cert_info, cert);
- tls_cert_get_chain_raw(ssock->pool, &ssock->local_cert_info, us, 1);
+ pj_pool_reset(ssock->info_pool);
+ tls_cert_get_chain_raw(ssock->info_pool, &ssock->local_cert_info, us, 1);
us_out:
tls_last_error = ret;
@@ -1077,7 +1078,8 @@ us_out:
goto peer_out;
tls_cert_get_info(ssock->pool, &ssock->remote_cert_info, cert);
- tls_cert_get_chain_raw(ssock->pool, &ssock->remote_cert_info, certs,
+ pj_pool_reset(ssock->info_pool);
+ tls_cert_get_chain_raw(ssock->info_pool, &ssock->remote_cert_info, certs,
certslen);
peer_out:
--- a/pjlib/src/pj/ssl_sock_imp_common.c
+++ b/pjlib/src/pj/ssl_sock_imp_common.c
@@ -616,6 +616,7 @@ static void ssl_on_destroy(void *arg)
}
/* Secure release pool, i.e: all memory blocks will be zeroed first */
+ pj_pool_secure_release(&ssock->info_pool);
pj_pool_secure_release(&ssock->pool);
}
@@ -1262,15 +1263,18 @@ PJ_DEF(pj_status_t) pj_ssl_sock_create (
{
pj_ssl_sock_t *ssock;
pj_status_t status;
+ pj_pool_t *info_pool;
PJ_ASSERT_RETURN(pool && param && p_ssock, PJ_EINVAL);
PJ_ASSERT_RETURN(param->sock_type == pj_SOCK_STREAM(), PJ_ENOTSUP);
+ info_pool = pj_pool_create(pool->factory, "ssl_chain%p", 512, 512, NULL);
pool = pj_pool_create(pool->factory, "ssl%p", 512, 512, NULL);
/* Create secure socket */
ssock = ssl_alloc(pool);
ssock->pool = pool;
+ ssock->info_pool = info_pool;
ssock->sock = PJ_INVALID_SOCKET;
ssock->ssl_state = SSL_STATE_NULL;
ssock->circ_buf_input.owner = ssock;
--- a/pjlib/src/pj/ssl_sock_imp_common.h
+++ b/pjlib/src/pj/ssl_sock_imp_common.h
@@ -96,6 +96,9 @@ typedef struct circ_buf_t {
struct pj_ssl_sock_t
{
pj_pool_t *pool;
+ pj_pool_t *info_pool; /* this is for certificate chain
+ * information allocation. Don't use for
+ * other purposes. */
pj_ssl_sock_t *parent;
pj_ssl_sock_param param;
pj_ssl_sock_param newsock_param;
--- a/pjlib/src/pj/ssl_sock_ossl.c
+++ b/pjlib/src/pj/ssl_sock_ossl.c
@@ -1641,11 +1641,12 @@ static void ssl_update_certs_info(pj_ssl
chain = SSL_get_peer_cert_chain(ossock->ossl_ssl);
if (chain) {
- ssl_update_remote_cert_chain_info(ssock->pool,
- &ssock->remote_cert_info,
- chain, PJ_TRUE);
+ pj_pool_reset(ssock->info_pool);
+ ssl_update_remote_cert_chain_info(ssock->info_pool,
+ &ssock->remote_cert_info,
+ chain, PJ_TRUE);
} else {
- ssock->remote_cert_info.raw_chain.cnt = 0;
+ ssock->remote_cert_info.raw_chain.cnt = 0;
}
}

View file

@ -1,187 +0,0 @@
From 9c6108ca392d5e0392e7fb5d2ffde85e3c44ce55 Mon Sep 17 00:00:00 2001
From: George Joseph <gjoseph@digium.com>
Date: Wed, 9 Oct 2019 07:50:32 -0600
Subject: [PATCH 31/31] transport regression fix
---
pjsip/src/pjsip/sip_transport.c | 73 +++++++++++++++++++++++++++------
1 file changed, 61 insertions(+), 12 deletions(-)
diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c
index 65ac823d4..da6b70e50 100644
--- a/pjsip/src/pjsip/sip_transport.c
+++ b/pjsip/src/pjsip/sip_transport.c
@@ -50,6 +50,24 @@ static const char *addr_string(const pj_sockaddr_t *addr)
str, sizeof(str));
return str;
}
+static const char* print_tpsel_info(const pjsip_tpselector *sel)
+{
+ static char tpsel_info_buf[80];
+ if (!sel) return "(null)";
+ if (sel->type==PJSIP_TPSELECTOR_LISTENER)
+ pj_ansi_snprintf(tpsel_info_buf, sizeof(tpsel_info_buf),
+ "listener[%s], reuse=%d", sel->u.listener->obj_name,
+ !sel->disable_connection_reuse);
+ else if (sel->type==PJSIP_TPSELECTOR_TRANSPORT)
+ pj_ansi_snprintf(tpsel_info_buf, sizeof(tpsel_info_buf),
+ "transport[%s], reuse=%d", sel->u.transport->info,
+ !sel->disable_connection_reuse);
+ else
+ pj_ansi_snprintf(tpsel_info_buf, sizeof(tpsel_info_buf),
+ "unknown[%p], reuse=%d", sel->u.ptr,
+ !sel->disable_connection_reuse);
+ return tpsel_info_buf;
+}
#else
# define TRACE_(x)
#endif
@@ -1210,10 +1228,14 @@ PJ_DEF(pj_status_t) pjsip_transport_register( pjsip_tpmgr *mgr,
* new transport to the list.
*/
pj_list_push_back(tp_ref, tp_add);
+ TRACE_((THIS_FILE, "Remote address already registered, "
+ "appended the transport to the list"));
} else {
/* Transport list not found, add it to the hash table. */
pj_hash_set_np(mgr->table, &tp->key, key_len, hval, tp_add->tp_buf,
tp_add);
+ TRACE_((THIS_FILE, "Remote address not registered, "
+ "added the transport to the hash"));
}
/* Add ref transport group lock, if any */
@@ -1283,6 +1305,13 @@ static pj_status_t destroy_transport( pjsip_tpmgr *mgr,
/* The transport list has multiple entry. */
pj_hash_set_np(mgr->table, &tp_next->tp->key, key_len,
hval, tp_next->tp_buf, tp_next);
+ TRACE_((THIS_FILE, "Hash entry updated after "
+ "transport %d being destroyed",
+ tp->obj_name));
+ } else {
+ TRACE_((THIS_FILE, "Hash entry deleted after "
+ "transport %d being destroyed",
+ tp->obj_name));
}
}
@@ -1294,6 +1323,14 @@ static pj_status_t destroy_transport( pjsip_tpmgr *mgr,
}
tp_iter = tp_iter->next;
} while (tp_iter != tp_ref);
+
+ if (tp_iter->tp != tp) {
+ PJ_LOG(3, (THIS_FILE, "Warning: transport %s being destroyed is "
+ "not registered", tp->obj_name));
+ }
+ } else {
+ PJ_LOG(3, (THIS_FILE, "Warning: transport %s being destroyed is "
+ "not found in the hash table", tp->obj_name));
}
pj_lock_release(mgr->lock);
@@ -2159,6 +2196,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport(pjsip_tpmgr *mgr,
NULL, tp);
}
+
/*
* pjsip_tpmgr_acquire_transport2()
*
@@ -2176,8 +2214,9 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
pjsip_tpfactory *factory;
pj_status_t status;
- TRACE_((THIS_FILE,"Acquiring transport type=%s, remote=%s:%d",
+ TRACE_((THIS_FILE,"Acquiring transport type=%s, sel=%s remote=%s:%d",
pjsip_transport_get_type_name(type),
+ print_tpsel_info(sel),
addr_string(remote),
pj_sockaddr_get_port(remote)));
@@ -2194,6 +2233,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
/* See if the transport is (not) suitable */
if (seltp->key.type != type) {
pj_lock_release(mgr->lock);
+ TRACE_((THIS_FILE, "Transport type in tpsel not matched"));
return PJSIP_ETPNOTSUITABLE;
}
@@ -2234,6 +2274,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
{
if (sel->u.listener->type != type) {
pj_lock_release(mgr->lock);
+ TRACE_((THIS_FILE, "Listener type in tpsel not matched"));
return PJSIP_ETPNOTSUITABLE;
}
}
@@ -2249,21 +2290,25 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
tp_entry = (transport *)pj_hash_get(mgr->table, &key, key_len,
NULL);
if (tp_entry) {
- if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER) {
- transport *tp_iter = tp_entry;
- do {
+ transport *tp_iter = tp_entry;
+ do {
+ /* Don't use transport being shutdown */
+ if (!tp_iter->tp->is_shutdown) {
if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&
- sel->u.listener &&
- tp_iter->tp->factory == sel->u.listener)
+ sel->u.listener)
{
+ /* Match listener if selector is set */
+ if (tp_iter->tp->factory == sel->u.listener) {
+ tp_ref = tp_iter->tp;
+ break;
+ }
+ } else {
tp_ref = tp_iter->tp;
break;
}
- tp_iter = tp_iter->next;
- } while (tp_iter != tp_entry);
- } else {
- tp_ref = tp_entry->tp;
- }
+ }
+ tp_iter = tp_iter->next;
+ } while (tp_iter != tp_entry);
}
}
@@ -2276,7 +2321,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
/* Ignore address for loop transports. */
if (type == PJSIP_TRANSPORT_LOOP ||
- type == PJSIP_TRANSPORT_LOOP_DGRAM)
+ type == PJSIP_TRANSPORT_LOOP_DGRAM)
{
pj_sockaddr *addr = &key.rem_addr;
@@ -2315,6 +2360,7 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
* 'duplicate' of the existing transport (same type & remote addr,
* but different factory).
*/
+ TRACE_((THIS_FILE, "Transport found but from different listener"));
}
if (tp_ref!=NULL && !tp_ref->is_shutdown) {
@@ -2347,10 +2393,13 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
*/
/* Verify that the listener type matches the destination type */
+ /* Already checked above. */
+ /*
if (sel->u.listener->type != type) {
pj_lock_release(mgr->lock);
return PJSIP_ETPNOTSUITABLE;
}
+ */
/* We'll use this listener to create transport */
factory = sel->u.listener;
--
2.21.0

View file

@ -1,84 +0,0 @@
From 8b8199180766e3eab6014feaa64ccaedcdc12816 Mon Sep 17 00:00:00 2001
From: Ben Ford <bford@digium.com>
Date: Mon, 23 Dec 2019 11:11:13 -0600
Subject: [PATCH] ICE: Add callback for finding valid pair.
It's possible to start sending as soon as one valid pair is found during
ICE negotiation. The reason we would want to do this is because it is
possible for a delay to occur at the start of a call for up to 3 seconds
until ICE negotiation has actually completed. More information can be
found here:
https://bugs.chromium.org/p/chromium/issues/detail?id=1024096
This patch adds a callback once a valid pair is found that applications
can use to start sending to avoid this scenario. Since only one valid
pair is needed to start media, we only trigger the callback once.
---
pjnath/include/pjnath/ice_session.h | 9 +++++++++
pjnath/src/pjnath/ice_session.c | 16 ++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/pjnath/include/pjnath/ice_session.h b/pjnath/include/pjnath/ice_session.h
index 15f0d04..8971220 100644
--- a/pjnath/include/pjnath/ice_session.h
+++ b/pjnath/include/pjnath/ice_session.h
@@ -468,6 +468,14 @@ typedef struct pj_ice_sess_cb
{
/**
* An optional callback that will be called by the ICE session when
+ * a valid pair has been found during ICE negotiation.
+ *
+ * @param ice The ICE session.
+ */
+ void (*on_valid_pair)(pj_ice_sess *ice);
+
+ /**
+ * An optional callback that will be called by the ICE session when
* ICE negotiation has completed, successfully or with failure.
*
* @param ice The ICE session.
@@ -625,6 +633,7 @@ struct pj_ice_sess
pj_bool_t is_nominating; /**< Nominating stage */
pj_bool_t is_complete; /**< Complete? */
pj_bool_t is_destroying; /**< Destroy is called */
+ pj_bool_t valid_pair_found; /**< First pair found */
pj_status_t ice_status; /**< Error status. */
pj_timer_entry timer; /**< ICE timer. */
pj_ice_sess_cb cb; /**< Callback. */
diff --git a/pjnath/src/pjnath/ice_session.c b/pjnath/src/pjnath/ice_session.c
index c51dba7..ed4138a 100644
--- a/pjnath/src/pjnath/ice_session.c
+++ b/pjnath/src/pjnath/ice_session.c
@@ -418,6 +418,8 @@ PJ_DEF(pj_status_t) pj_ice_sess_create(pj_stun_config *stun_cfg,
pj_list_init(&ice->early_check);
+ ice->valid_pair_found = PJ_FALSE;
+
/* Done */
*p_ice = ice;
@@ -1348,6 +1350,20 @@ static pj_bool_t on_check_complete(pj_ice_sess *ice,
GET_CHECK_ID(&ice->clist, check),
(check->nominated ? " and nominated" : "")));
+ {
+ /* On the first valid pair, we call the callback, if present */
+ if (ice->valid_pair_found == PJ_FALSE) {
+ void (*on_valid_pair)(pj_ice_sess *ice);
+
+ ice->valid_pair_found = PJ_TRUE;
+ on_valid_pair = ice->cb.on_valid_pair;
+
+ if (on_valid_pair) {
+ (*on_valid_pair)(ice);
+ }
+ }
+ }
+
}
/* 8.2. Updating States
--
2.7.4

View file

@ -1,40 +0,0 @@
From 6324760c2fb0ffeb2e29c6c0a96a33906caa8d5f Mon Sep 17 00:00:00 2001
From: Sean Bright <sean.bright@gmail.com>
Date: Thu, 16 Jan 2020 10:46:11 -0500
Subject: [PATCH] sip_parser.c: Allow brackets in via parameters
From RFC 5118 section 4.5:
While it would be beneficial if the same non-terminal
("IPv6reference") was used for both the "sent-by" and "via-received"
production rules, there has not been a consensus in the working group
to that effect. Thus, the best that can be suggested is that
implementations must follow the Robustness Principle [RFC1122] and be
liberal in accepting a "received" parameter with or without the
delimiting "[" and "]" tokens. When sending a request,
implementations must not put the delimiting "[" and "]" tokens.
---
pjsip/src/pjsip/sip_parser.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pjsip/src/pjsip/sip_parser.c b/pjsip/src/pjsip/sip_parser.c
index e01e672fb..4f9c7fca4 100644
--- a/pjsip/src/pjsip/sip_parser.c
+++ b/pjsip/src/pjsip/sip_parser.c
@@ -384,11 +384,11 @@ static pj_status_t init_parser()
status = pj_cis_dup(&pconst.pjsip_VIA_PARAM_SPEC, &pconst.pjsip_TOKEN_SPEC);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
- pj_cis_add_str(&pconst.pjsip_VIA_PARAM_SPEC, ":");
+ pj_cis_add_str(&pconst.pjsip_VIA_PARAM_SPEC, "[:]");
status = pj_cis_dup(&pconst.pjsip_VIA_PARAM_SPEC_ESC, &pconst.pjsip_TOKEN_SPEC_ESC);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
- pj_cis_add_str(&pconst.pjsip_VIA_PARAM_SPEC_ESC, ":");
+ pj_cis_add_str(&pconst.pjsip_VIA_PARAM_SPEC_ESC, "[:]");
status = pj_cis_dup(&pconst.pjsip_HOST_SPEC, &pconst.pjsip_ALNUM_SPEC);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
--
2.20.1

View file

@ -0,0 +1,68 @@
From 78683646c8bc670ec730a42494e075f671a08e28 Mon Sep 17 00:00:00 2001
From: Guido Falsi <mad@madpilot.net>
Date: Mon, 11 May 2020 08:50:39 +0200
Subject: [PATCH] Fix race condition in parallel builds (#2426)
* Some targets residing in `OBJDIRS` are missing a dependency on that directory, which results in a race condition, causing build to fail sometimes due to the directory not existing when running parallel builds.
* The `PJSUA_LIB` variable is not defined anywhere, resulting in an empty value, and no correct dependency on the pjsua shared library for `pjsua2`. The correct variable seems to be `PJSUA_LIB_LIB`, defined at the start of this same `Makefile`.
---
build/rules.mak | 12 ++++++------
pjsip/build/Makefile | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
--- a/build/rules.mak
+++ b/build/rules.mak
@@ -129,7 +129,7 @@ endif
$(OBJDIR)/$(app).o: $(OBJDIRS) $(OBJS)
$(CROSS_COMPILE)ld -r -o $@ $(OBJS)
-$(OBJDIR)/$(app).ko: $(OBJDIR)/$(app).o
+$(OBJDIR)/$(app).ko: $(OBJDIR)/$(app).o | $(OBJDIRS)
@echo Creating kbuild Makefile...
@echo "# Our module name:" > $(OBJDIR)/Makefile
@echo 'obj-m += $(app).o' >> $(OBJDIR)/Makefile
@@ -154,27 +154,27 @@ $(OBJDIR)/$(app).ko: $(OBJDIR)/$(app).o
../lib/$(app).ko: $(LIB) $(OBJDIR)/$(app).ko
cp $(OBJDIR)/$(app).ko ../lib
-$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.m
+$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.m | $(OBJDIRS)
$(CC) $($(APP)_CFLAGS) \
$(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
$(subst /,$(HOST_PSEP),$<)
-$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.c
+$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.c | $(OBJDIRS)
$(CC) $($(APP)_CFLAGS) \
$(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
$(subst /,$(HOST_PSEP),$<)
-$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.S
+$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.S | $(OBJDIRS)
$(CC) $($(APP)_CFLAGS) \
$(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
$(subst /,$(HOST_PSEP),$<)
-$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.cpp
+$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.cpp | $(OBJDIRS)
$(CXX) $($(APP)_CXXFLAGS) \
$(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
$(subst /,$(HOST_PSEP),$<)
-$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.cc
+$(OBJDIR)/%$(OBJEXT): $(SRCDIR)/%.cc | $(OBJDIRS)
$(CXX) $($(APP)_CXXFLAGS) \
$(CC_OUT)$(subst /,$(HOST_PSEP),$@) \
$(subst /,$(HOST_PSEP),$<)
--- a/pjsip/build/Makefile
+++ b/pjsip/build/Makefile
@@ -261,7 +261,7 @@ $(PJSUA_LIB_LIB) $(PJSUA_LIB_SONAME): $(
pjsua2-lib: $(PJSUA2_LIB_LIB)
$(PJSUA2_LIB_SONAME): $(PJSUA2_LIB_LIB)
-$(PJSUA2_LIB_LIB) $(PJSUA2_LIB_SONAME): $(PJSUA_LIB) $(PSJUA_LIB_SONAME) $(PJSIP_LIB) $(PJSIP_SONAME) $(PJSIP_SIMPLE_LIB) $(PJSIP_SIMPLE_SONAME) $(PJSIP_UA_LIB) $(PJSIP_UA_SONAME)
+$(PJSUA2_LIB_LIB) $(PJSUA2_LIB_SONAME): $(PJSUA_LIB_LIB) $(PJSUA_LIB_SONAME) $(PJSIP_LIB) $(PJSIP_SONAME) $(PJSIP_SIMPLE_LIB) $(PJSIP_SIMPLE_SONAME) $(PJSIP_UA_LIB) $(PJSIP_UA_SONAME)
$(MAKE) -f $(RULES_MAK) APP=PJSUA2_LIB app=pjsua2-lib $(subst /,$(HOST_PSEP),$(LIBDIR)/$@)
pjsip-test: $(TEST_EXE)

View file

@ -0,0 +1,27 @@
--- a/pjmedia/src/pjmedia/sdp_neg.c
+++ b/pjmedia/src/pjmedia/sdp_neg.c
@@ -906,7 +906,7 @@ static pj_status_t process_m_answer( pj_
* after receiving remote answer.
*/
static pj_status_t process_answer(pj_pool_t *pool,
- pjmedia_sdp_session *offer,
+ pjmedia_sdp_session *local_offer,
pjmedia_sdp_session *answer,
pj_bool_t allow_asym,
pjmedia_sdp_session **p_active)
@@ -914,10 +914,14 @@ static pj_status_t process_answer(pj_poo
unsigned omi = 0; /* Offer media index */
unsigned ami = 0; /* Answer media index */
pj_bool_t has_active = PJ_FALSE;
+ pjmedia_sdp_session *offer;
pj_status_t status;
/* Check arguments. */
- PJ_ASSERT_RETURN(pool && offer && answer && p_active, PJ_EINVAL);
+ PJ_ASSERT_RETURN(pool && local_offer && answer && p_active, PJ_EINVAL);
+
+ /* Duplicate local offer SDP. */
+ offer = pjmedia_sdp_session_clone(pool, local_offer);
/* Check that media count match between offer and answer */
// Ticket #527, different media count is allowed for more interoperability,