pjproject_bundled: Move to pjproject 2.5

Although all the patches we had against 2.4.5 were applied by Teluu,
a new bug was introduced preventing re-use of tcp and tls transports
This patch removes all the previous patches against 2.4.5, updates
the version to 2.5, and adds a new patch to correct the transport
re-use problem.

Change-Id: I0dc6c438c3910f7887418a5832ca186aea23d068
(cherry picked from commit e8abfdcdc5)
changes/41/2941/1
George Joseph 9 years ago
parent 942870160f
commit aab8bc5d31

@ -1,224 +0,0 @@
diff --git a/pjlib/include/pj/ssl_sock.h b/pjlib/include/pj/ssl_sock.h
index 1682bda..a69af32 100644
--- a/pjlib/include/pj/ssl_sock.h
+++ b/pjlib/include/pj/ssl_sock.h
@@ -864,6 +864,18 @@ PJ_DECL(void) pj_ssl_sock_param_default(pj_ssl_sock_param *param);
/**
+ * Duplicate pj_ssl_sock_param.
+ *
+ * @param pool Pool to allocate memory.
+ * @param dst Destination parameter.
+ * @param src Source parameter.
+ */
+PJ_DECL(void) pj_ssl_sock_param_copy(pj_pool_t *pool,
+ pj_ssl_sock_param *dst,
+ const pj_ssl_sock_param *src);
+
+
+/**
* Create secure socket instance.
*
* @param pool The pool for allocating secure socket instance.
@@ -1115,6 +1127,30 @@ PJ_DECL(pj_status_t) pj_ssl_sock_start_accept(pj_ssl_sock_t *ssock,
/**
+ * Same as #pj_ssl_sock_start_accept(), but application can provide
+ * a secure socket parameter, which will be used to create a new secure
+ * socket reported in \a on_accept_complete() callback when there is
+ * an incoming connection.
+ *
+ * @param ssock The secure socket.
+ * @param pool Pool used to allocate some internal data for the
+ * operation.
+ * @param localaddr Local address to bind on.
+ * @param addr_len Length of buffer containing local address.
+ * @param newsock_param Secure socket parameter for new accepted sockets.
+ *
+ * @return PJ_SUCCESS if the operation has been successful,
+ * or the appropriate error code on failure.
+ */
+PJ_DECL(pj_status_t)
+pj_ssl_sock_start_accept2(pj_ssl_sock_t *ssock,
+ pj_pool_t *pool,
+ const pj_sockaddr_t *local_addr,
+ int addr_len,
+ const pj_ssl_sock_param *newsock_param);
+
+
+/**
* Starts asynchronous socket connect() operation and SSL/TLS handshaking
* for this socket. Once the connection is done (either successfully or not),
* the \a on_connect_complete() callback will be called.
diff --git a/pjlib/src/pj/ssl_sock_common.c b/pjlib/src/pj/ssl_sock_common.c
index 913efee..717ab1d 100644
--- a/pjlib/src/pj/ssl_sock_common.c
+++ b/pjlib/src/pj/ssl_sock_common.c
@@ -19,6 +19,7 @@
#include <pj/ssl_sock.h>
#include <pj/assert.h>
#include <pj/errno.h>
+#include <pj/pool.h>
#include <pj/string.h>
/*
@@ -48,6 +49,31 @@ PJ_DEF(void) pj_ssl_sock_param_default(pj_ssl_sock_param *param)
}
+/*
+ * Duplicate SSL socket parameter.
+ */
+PJ_DEF(void) pj_ssl_sock_param_copy( pj_pool_t *pool,
+ pj_ssl_sock_param *dst,
+ const pj_ssl_sock_param *src)
+{
+ /* Init secure socket param */
+ pj_memcpy(dst, src, sizeof(*dst));
+ if (src->ciphers_num > 0) {
+ unsigned i;
+ dst->ciphers = (pj_ssl_cipher*)
+ pj_pool_calloc(pool, src->ciphers_num,
+ sizeof(pj_ssl_cipher));
+ for (i = 0; i < src->ciphers_num; ++i)
+ dst->ciphers[i] = src->ciphers[i];
+ }
+
+ if (src->server_name.slen) {
+ /* Server name must be null-terminated */
+ pj_strdup_with_null(pool, &dst->server_name, &src->server_name);
+ }
+}
+
+
PJ_DEF(pj_status_t) pj_ssl_cert_get_verify_status_strings(
pj_uint32_t verify_status,
const char *error_strings[],
diff --git a/pjlib/src/pj/ssl_sock_ossl.c b/pjlib/src/pj/ssl_sock_ossl.c
index 40a5a1e..6a701b7 100644
--- a/pjlib/src/pj/ssl_sock_ossl.c
+++ b/pjlib/src/pj/ssl_sock_ossl.c
@@ -141,6 +141,7 @@ struct pj_ssl_sock_t
pj_pool_t *pool;
pj_ssl_sock_t *parent;
pj_ssl_sock_param param;
+ pj_ssl_sock_param newsock_param;
pj_ssl_cert_t *cert;
pj_ssl_cert_info local_cert_info;
@@ -1757,11 +1758,9 @@ static pj_bool_t asock_on_accept_complete (pj_activesock_t *asock,
unsigned i;
pj_status_t status;
- PJ_UNUSED_ARG(src_addr_len);
-
/* Create new SSL socket instance */
- status = pj_ssl_sock_create(ssock_parent->pool, &ssock_parent->param,
- &ssock);
+ status = pj_ssl_sock_create(ssock_parent->pool,
+ &ssock_parent->newsock_param, &ssock);
if (status != PJ_SUCCESS)
goto on_return;
@@ -2183,20 +2182,8 @@ PJ_DEF(pj_status_t) pj_ssl_sock_create (pj_pool_t *pool,
return status;
/* Init secure socket param */
- ssock->param = *param;
+ pj_ssl_sock_param_copy(pool, &ssock->param, param);
ssock->param.read_buffer_size = ((ssock->param.read_buffer_size+7)>>3)<<3;
- if (param->ciphers_num > 0) {
- unsigned i;
- ssock->param.ciphers = (pj_ssl_cipher*)
- pj_pool_calloc(pool, param->ciphers_num,
- sizeof(pj_ssl_cipher));
- for (i = 0; i < param->ciphers_num; ++i)
- ssock->param.ciphers[i] = param->ciphers[i];
- }
-
- /* Server name must be null-terminated */
- pj_strdup_with_null(pool, &ssock->param.server_name,
- &param->server_name);
/* Finally */
*p_ssock = ssock;
@@ -2617,12 +2604,36 @@ PJ_DEF(pj_status_t) pj_ssl_sock_start_accept (pj_ssl_sock_t *ssock,
const pj_sockaddr_t *localaddr,
int addr_len)
{
+ return pj_ssl_sock_start_accept2(ssock, pool, localaddr, addr_len,
+ &ssock->param);
+}
+
+
+/**
+ * Same as #pj_ssl_sock_start_accept(), but application provides parameter
+ * for new accepted secure sockets.
+ */
+PJ_DEF(pj_status_t)
+pj_ssl_sock_start_accept2(pj_ssl_sock_t *ssock,
+ pj_pool_t *pool,
+ const pj_sockaddr_t *localaddr,
+ int addr_len,
+ const pj_ssl_sock_param *newsock_param)
+{
pj_activesock_cb asock_cb;
pj_activesock_cfg asock_cfg;
pj_status_t status;
PJ_ASSERT_RETURN(ssock && pool && localaddr && addr_len, PJ_EINVAL);
+ /* Verify new socket parameters */
+ if (newsock_param->grp_lock != ssock->param.grp_lock ||
+ newsock_param->sock_af != ssock->param.sock_af ||
+ newsock_param->sock_type != ssock->param.sock_type)
+ {
+ return PJ_EINVAL;
+ }
+
/* Create socket */
status = pj_sock_socket(ssock->param.sock_af, ssock->param.sock_type, 0,
&ssock->sock);
@@ -2691,6 +2702,7 @@ PJ_DEF(pj_status_t) pj_ssl_sock_start_accept (pj_ssl_sock_t *ssock,
goto on_error;
/* Start accepting */
+ pj_ssl_sock_param_copy(pool, &ssock->newsock_param, newsock_param);
status = pj_activesock_start_accept(ssock->asock, pool);
if (status != PJ_SUCCESS)
goto on_error;
diff --git a/pjsip/src/pjsip/sip_transport_tls.c b/pjsip/src/pjsip/sip_transport_tls.c
index a9e95fb..91d99a7 100644
--- a/pjsip/src/pjsip/sip_transport_tls.c
+++ b/pjsip/src/pjsip/sip_transport_tls.c
@@ -314,7 +314,7 @@ PJ_DEF(pj_status_t) pjsip_tls_transport_start2( pjsip_endpoint *endpt,
int af, sip_ssl_method;
pj_uint32_t sip_ssl_proto;
struct tls_listener *listener;
- pj_ssl_sock_param ssock_param;
+ pj_ssl_sock_param ssock_param, newsock_param;
pj_sockaddr *listener_addr;
pj_bool_t has_listener;
pj_status_t status;
@@ -473,9 +473,14 @@ PJ_DEF(pj_status_t) pjsip_tls_transport_start2( pjsip_endpoint *endpt,
*/
has_listener = PJ_FALSE;
- status = pj_ssl_sock_start_accept(listener->ssock, pool,
+ pj_memcpy(&newsock_param, &ssock_param, sizeof(newsock_param));
+ newsock_param.async_cnt = 1;
+ newsock_param.cb.on_data_read = &on_data_read;
+ newsock_param.cb.on_data_sent = &on_data_sent;
+ status = pj_ssl_sock_start_accept2(listener->ssock, pool,
(pj_sockaddr_t*)listener_addr,
- pj_sockaddr_get_len((pj_sockaddr_t*)listener_addr));
+ pj_sockaddr_get_len((pj_sockaddr_t*)listener_addr),
+ &newsock_param);
if (status == PJ_SUCCESS || status == PJ_EPENDING) {
pj_ssl_sock_info info;
has_listener = PJ_TRUE;
--
cgit v0.11.2

@ -1,70 +0,0 @@
From a147b72df1ec150c1d733e882225db86142fb339 Mon Sep 17 00:00:00 2001
From: George Joseph <george.joseph@fairview5.com>
Date: Sun, 21 Feb 2016 10:01:53 -0700
Subject: [PATCH] Bump tcp/tls and transaction log levels from 1 to 3
sip_transport_tcp, sip_transport_tls and sip_transaction are printing messages
at log level 1 or 2 for things that are transient, recoverable, possibly
expected, or are handled with return codes. A good example of this is if we're
trying to send an OPTIONS message to a TCP client that has disappeared. Both
sip_transport_tcp and sip_transaction are printing "connection refused"
messages because the remote client isn't listening. This is generally expected
behavior and it should be up to the app caller to determine if an error message
is warranted.
---
pjsip/src/pjsip/sip_transaction.c | 4 ++--
pjsip/src/pjsip/sip_transport_tcp.c | 2 +-
pjsip/src/pjsip/sip_transport_tls.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/pjsip/src/pjsip/sip_transaction.c b/pjsip/src/pjsip/sip_transaction.c
index 46bd971..1b4fdb7 100644
--- a/pjsip/src/pjsip/sip_transaction.c
+++ b/pjsip/src/pjsip/sip_transaction.c
@@ -1898,7 +1898,7 @@ static void send_msg_callback( pjsip_send_state *send_state,
err =pj_strerror((pj_status_t)-sent, errmsg, sizeof(errmsg));
- PJ_LOG(2,(tsx->obj_name,
+ PJ_LOG(3,(tsx->obj_name,
"Failed to send %s! err=%d (%s)",
pjsip_tx_data_get_info(send_state->tdata), -sent,
errmsg));
@@ -1938,7 +1938,7 @@ static void send_msg_callback( pjsip_send_state *send_state,
}
} else {
- PJ_PERROR(2,(tsx->obj_name, (pj_status_t)-sent,
+ PJ_PERROR(3,(tsx->obj_name, (pj_status_t)-sent,
"Temporary failure in sending %s, "
"will try next server",
pjsip_tx_data_get_info(send_state->tdata)));
diff --git a/pjsip/src/pjsip/sip_transport_tcp.c b/pjsip/src/pjsip/sip_transport_tcp.c
index 222cb13..1bbb324 100644
--- a/pjsip/src/pjsip/sip_transport_tcp.c
+++ b/pjsip/src/pjsip/sip_transport_tcp.c
@@ -164,7 +164,7 @@ static void tcp_perror(const char *sender, const char *title,
pj_strerror(status, errmsg, sizeof(errmsg));
- PJ_LOG(1,(sender, "%s: %s [code=%d]", title, errmsg, status));
+ PJ_LOG(3,(sender, "%s: %s [code=%d]", title, errmsg, status));
}
diff --git a/pjsip/src/pjsip/sip_transport_tls.c b/pjsip/src/pjsip/sip_transport_tls.c
index 617d7f5..a83ac32 100644
--- a/pjsip/src/pjsip/sip_transport_tls.c
+++ b/pjsip/src/pjsip/sip_transport_tls.c
@@ -170,7 +170,7 @@ static void tls_perror(const char *sender, const char *title,
pj_strerror(status, errmsg, sizeof(errmsg));
- PJ_LOG(1,(sender, "%s: %s [code=%d]", title, errmsg, status));
+ PJ_LOG(3,(sender, "%s: %s [code=%d]", title, errmsg, status));
}
--
2.5.0

@ -1,80 +0,0 @@
From b5c0bc905911f75e08987e6833075481fe16dab2 Mon Sep 17 00:00:00 2001
From: George Joseph <george.joseph@fairview5.com>
Date: Mon, 22 Feb 2016 13:05:59 -0700
Subject: [PATCH] ioqueue: Enable epoll in aconfigure.ac
Although the --enable-epoll option was being accepted, the result
was always forced to select. This patch updates aconfigure.ac
to properly set the value of ac_linux_poll if --enable-epoll is
specified.
---
README.txt | 1 +
aconfigure | 11 +++++++----
aconfigure.ac | 7 +++++--
pjlib/include/pj/compat/os_auto.h.in | 3 +++
4 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/README.txt b/README.txt
index bc45da8..48415fd 100644
--- a/README.txt
+++ b/README.txt
@@ -463,6 +463,7 @@ Using Default Settings
$ ./configure --help
...
Optional Features:
+ --enable-epoll Use epoll on Linux instead of select
--disable-floating-point Disable floating point where possible
--disable-sound Exclude sound (i.e. use null sound)
--disable-small-filter Exclude small filter in resampling
diff --git a/aconfigure.ac b/aconfigure.ac
index 2f71abb..3e88124 100644
--- a/aconfigure.ac
+++ b/aconfigure.ac
@@ -410,6 +410,7 @@ dnl ######################
dnl # ioqueue selection
dnl #
AC_SUBST(ac_os_objs)
+AC_SUBST(ac_linux_poll)
AC_MSG_CHECKING([ioqueue backend])
AC_ARG_ENABLE(epoll,
AC_HELP_STRING([--enable-epoll],
@@ -417,10 +418,13 @@ AC_ARG_ENABLE(epoll,
[
ac_os_objs=ioqueue_epoll.o
AC_MSG_RESULT([/dev/epoll])
+ AC_DEFINE(PJ_HAS_LINUX_EPOLL,1)
+ ac_linux_poll=epoll
],
[
ac_os_objs=ioqueue_select.o
- AC_MSG_RESULT([select()])
+ AC_MSG_RESULT([select()])
+ ac_linux_poll=select
])
AC_SUBST(ac_shared_libraries)
@@ -1879,7 +1883,6 @@ esac
AC_SUBST(target)
-AC_SUBST(ac_linux_poll,select)
AC_SUBST(ac_host,unix)
AC_SUBST(ac_main_obj)
case $target in
diff --git a/pjlib/include/pj/compat/os_auto.h.in b/pjlib/include/pj/compat/os_auto.h.in
index 77980d3..c8e73b2 100644
--- a/pjlib/include/pj/compat/os_auto.h.in
+++ b/pjlib/include/pj/compat/os_auto.h.in
@@ -128,6 +128,9 @@
*/
#undef PJ_SELECT_NEEDS_NFDS
+/* Was Linux epoll support enabled */
+#undef PJ_HAS_LINUX_EPOLL
+
/* Is errno a good way to retrieve OS errors?
*/
#undef PJ_HAS_ERRNO_VAR
--
2.5.0

@ -1,114 +0,0 @@
From 552194179eb6deae8326eb0fef446e69240ea41b Mon Sep 17 00:00:00 2001
From: George Joseph <george.joseph@fairview5.com>
Date: Fri, 19 Feb 2016 17:05:53 -0700
Subject: [PATCH] sip_transport: Search for transport even if listener was
specified.
If a listener was specified when calling pjsip_tpmgr_acquire_transport2,
a new transport was always created instead of using an existing one. This
caused several issues mostly related to the remote end not expecting a new
connection. I.E. A TCP client who registered to a server is not going to
be listening for connections coming back from the server and refuses the
connection.
Now when pjsip_tpmgr_acquire_transport2 is called with a listener, the
registry is still searched for an existing transport and the listener
is used as a factory only if no existing transport can be found.
---
pjsip/src/pjsip/sip_transport.c | 68 ++++++++++++++++++++---------------------
1 file changed, 34 insertions(+), 34 deletions(-)
diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c
index 0410324..620b9c0 100644
--- a/pjsip/src/pjsip/sip_transport.c
+++ b/pjsip/src/pjsip/sip_transport.c
@@ -1999,29 +1999,11 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
TRACE_((THIS_FILE, "Transport %s acquired", seltp->obj_name));
return PJ_SUCCESS;
-
-
- } else if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&
- sel->u.listener)
- {
- /* Application has requested that a specific listener is to
- * be used. In this case, skip transport hash table lookup.
- */
-
- /* Verify that the listener type matches the destination type */
- 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;
-
} else {
/*
* This is the "normal" flow, where application doesn't specify
- * specific transport/listener to be used to send message to.
+ * specific transport to be used to send message to.
* In this case, lookup the transport from the hash table.
*/
pjsip_transport_key key;
@@ -2081,22 +2063,40 @@ PJ_DEF(pj_status_t) pjsip_tpmgr_acquire_transport2(pjsip_tpmgr *mgr,
return PJ_SUCCESS;
}
- /*
- * Transport not found!
- * Find factory that can create such transport.
- */
- factory = mgr->factory_list.next;
- while (factory != &mgr->factory_list) {
- if (factory->type == type)
- break;
- factory = factory->next;
- }
+ if (sel && sel->type == PJSIP_TPSELECTOR_LISTENER &&
+ sel->u.listener)
+ {
+ /* Application has requested that a specific listener is to
+ * be used.
+ */
+
+ /* Verify that the listener type matches the destination type */
+ if (sel->u.listener->type != type) {
+ pj_lock_release(mgr->lock);
+ return PJSIP_ETPNOTSUITABLE;
+ }
- if (factory == &mgr->factory_list) {
- /* No factory can create the transport! */
- pj_lock_release(mgr->lock);
- TRACE_((THIS_FILE, "No suitable factory was found either"));
- return PJSIP_EUNSUPTRANSPORT;
+ /* We'll use this listener to create transport */
+ factory = sel->u.listener;
+
+ } else {
+ /*
+ * Transport not found!
+ * Find factory that can create such transport.
+ */
+ factory = mgr->factory_list.next;
+ while (factory != &mgr->factory_list) {
+ if (factory->type == type)
+ break;
+ factory = factory->next;
+ }
+
+ if (factory == &mgr->factory_list) {
+ /* No factory can create the transport! */
+ pj_lock_release(mgr->lock);
+ TRACE_((THIS_FILE, "No suitable factory was found either"));
+ return PJSIP_EUNSUPTRANSPORT;
+ }
}
}
--
2.5.0

@ -0,0 +1,48 @@
From b7cb93b0e1729589a71e8b30d9a9893f0918e2a2 Mon Sep 17 00:00:00 2001
From: George Joseph <george.joseph@fairview5.com>
Date: Mon, 30 May 2016 11:58:22 -0600
Subject: [PATCH] sip_transport_tcp/tls: Set factory on transports created
from accept
The ability to re-use tcp and tls transports when a factory is
specified now depends on transport->factory being set which is a new field
in 2.5. This was being set only on new outgoing sockets not on
incoming sockets. The result was that a client REGISTER created a new
socket but without the factory set, the next outgoing request to the
client, OPTIONS, INVITE, etc, would attempt to create another socket
which the client would refuse.
This patch sets the factory on transports created as a result of an
accept.
---
pjsip/src/pjsip/sip_transport_tcp.c | 1 +
pjsip/src/pjsip/sip_transport_tls.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/pjsip/src/pjsip/sip_transport_tcp.c b/pjsip/src/pjsip/sip_transport_tcp.c
index 1bbb324..00eb8fc 100644
--- a/pjsip/src/pjsip/sip_transport_tcp.c
+++ b/pjsip/src/pjsip/sip_transport_tcp.c
@@ -713,6 +713,7 @@ static pj_status_t tcp_create( struct tcp_listener *listener,
tcp->base.send_msg = &tcp_send_msg;
tcp->base.do_shutdown = &tcp_shutdown;
tcp->base.destroy = &tcp_destroy_transport;
+ tcp->base.factory = &listener->factory;
/* Create group lock */
status = pj_grp_lock_create(pool, NULL, &tcp->grp_lock);
diff --git a/pjsip/src/pjsip/sip_transport_tls.c b/pjsip/src/pjsip/sip_transport_tls.c
index a83ac32..36ee70d 100644
--- a/pjsip/src/pjsip/sip_transport_tls.c
+++ b/pjsip/src/pjsip/sip_transport_tls.c
@@ -742,6 +742,7 @@ static pj_status_t tls_create( struct tls_listener *listener,
tls->base.send_msg = &tls_send_msg;
tls->base.do_shutdown = &tls_shutdown;
tls->base.destroy = &tls_destroy_transport;
+ tls->base.factory = &listener->factory;
tls->ssock = ssock;
--
2.5.5

@ -1,48 +0,0 @@
From 1281b60a1807d1285b101b6eb61c6478f29785fe Mon Sep 17 00:00:00 2001
From: George Joseph <george.joseph@fairview5.com>
Date: Wed, 23 Mar 2016 07:48:52 -0600
Subject: [PATCH] aconfigure.ac: Fix autoconf issue with opencore-amrnb on
older systems
autoconf 2.63 on CentOS6 produces a bad ./aconfigure file related to
opencore-amrnb.
./aconfigure: line 15158: syntax error near unexpected token `fi'
To get around this, a 'true;' needed to be added to the Ok case of
AC_ARG_WITH(opencore-amrnb)
---
aconfigure | 3 +++
aconfigure.ac | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/aconfigure b/aconfigure
index 33a08f5..4c122c2 100755
--- a/aconfigure
+++ b/aconfigure
@@ -7908,6 +7908,9 @@ fi
# Check whether --with-opencore-amrnb was given.
if test "${with_opencore_amrnb+set}" = set; then :
withval=$with_opencore_amrnb; as_fn_error $? "This option is obsolete and replaced by --with-opencore-amr=DIR" "$LINENO" 5
+else
+ true;
+
fi
diff --git a/aconfigure.ac b/aconfigure.ac
index 3e88124..5d3e833 100644
--- a/aconfigure.ac
+++ b/aconfigure.ac
@@ -1631,7 +1631,7 @@ AC_ARG_WITH(opencore-amrnb,
AC_HELP_STRING([--with-opencore-amrnb=DIR],
[This option is obsolete and replaced by --with-opencore-amr=DIR]),
[AC_MSG_ERROR(This option is obsolete and replaced by --with-opencore-amr=DIR)],
- []
+ [true;]
)
dnl # opencore-amr alt prefix
--
2.5.0

@ -1,2 +1,2 @@
PJPROJECT_VERSION = 2.4.5
PJPROJECT_VERSION = 2.5

Loading…
Cancel
Save