summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--apps/app_voicemail.c39
-rwxr-xr-xconfigure28
-rw-r--r--configure.ac12
-rw-r--r--include/asterisk/res_pjsip_session.h11
-rw-r--r--makeopts.in2
-rw-r--r--res/res_pjsip_mwi.c6
-rw-r--r--res/res_pjsip_refer.c8
-rw-r--r--res/res_pjsip_session.c29
-rw-r--r--res/res_pjsip_session.exports.in1
-rw-r--r--res/res_pjsip_transport_websocket.c4
-rw-r--r--res/res_rtp_asterisk.c2
-rw-r--r--third-party/pjproject/Makefile2
-rw-r--r--third-party/pjproject/Makefile.rules2
14 files changed, 141 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index f29c07f68..85a1152ea 100644
--- a/Makefile
+++ b/Makefile
@@ -124,6 +124,9 @@ _ASTLDFLAGS+=$(LDOPTS)
# libxml2 cflags
_ASTCFLAGS+=$(LIBXML2_INCLUDE)
+# BIND_8_COMPAT
+_ASTCFLAGS+=$(BIND8_CFLAGS)
+
#Uncomment this to see all build commands instead of 'quiet' output
#NOISY_BUILD=yes
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 06f4830fa..8f50e1106 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -2730,7 +2730,7 @@ static int imap_store_file(const char *dir, const char *mailboxuser, const char
}
if (fread(buf, 1, len, p) != len) {
if (ferror(p)) {
- ast_log(LOG_ERROR, "Error while reading mail file: %s\n");
+ ast_log(LOG_ERROR, "Error while reading mail file: %s\n", tmp);
return -1;
}
}
@@ -13106,6 +13106,40 @@ static void mwi_sub_destroy(struct mwi_sub *mwi_sub)
ast_free(mwi_sub);
}
+#ifdef IMAP_STORAGE
+static void imap_logout(const char *mailbox_id)
+{
+ char *context;
+ char *mailbox;
+ struct ast_vm_user vmus;
+ RAII_VAR(struct ast_vm_user *, vmu, NULL, free_user);
+ struct vm_state *vms = NULL;
+
+ if (ast_strlen_zero(mailbox_id)
+ || separate_mailbox(ast_strdupa(mailbox_id), &mailbox, &context)) {
+ return;
+ }
+
+ memset(&vmus, 0, sizeof(vmus));
+
+ if (!(vmu = find_user(&vmus, context, mailbox)) || vmu->imapuser[0] == '\0') {
+ return;
+ }
+
+ vms = get_vm_state_by_imapuser(vmu->imapuser, 0);
+ if (!vms) {
+ vms = get_vm_state_by_mailbox(mailbox, context, 0);
+ }
+ if (!vms) {
+ return;
+ }
+
+ vms->mailstream = mail_close(vms->mailstream);
+ vmstate_delete(vms);
+}
+
+#endif
+
static int handle_unsubscribe(void *datap)
{
struct mwi_sub *mwi_sub;
@@ -13117,6 +13151,9 @@ static int handle_unsubscribe(void *datap)
AST_LIST_REMOVE_CURRENT(entry);
/* Don't break here since a duplicate uniqueid
* may have been added as a result of a cache dump. */
+#ifdef IMAP_STORAGE
+ imap_logout(mwi_sub->mailbox);
+#endif
mwi_sub_destroy(mwi_sub);
}
}
diff --git a/configure b/configure
index 39ed49457..361af8884 100755
--- a/configure
+++ b/configure
@@ -697,6 +697,7 @@ PBX_IP_MTU_DISCOVER
PBX_RTLD_NOLOAD
PBX_GLOB_BRACE
PBX_GLOB_NOMAGIC
+BIND8_CFLAGS
AST_RPATH
AST_NATIVE_ARCH
AST_SHADOW_WARNINGS
@@ -19408,6 +19409,33 @@ fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BIND_8_COMPAT required" >&5
+$as_echo_n "checking for BIND_8_COMPAT required... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#undef BIND_8_COMPAT
+#include <arpa/nameser.h>
+
+int
+main ()
+{
+int x = NXDOMAIN
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+BIND8_CFLAGS=-DBIND_8_COMPAT
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
if test "x${PBX_GLOB_NOMAGIC}" != "x1"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLOB_NOMAGIC in glob.h" >&5
diff --git a/configure.ac b/configure.ac
index d7fb2171e..ecbe87093 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1361,6 +1361,18 @@ AC_LINK_IFELSE(
AC_MSG_RESULT(no)
)
+AC_MSG_CHECKING(for BIND_8_COMPAT required)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[
+#undef BIND_8_COMPAT
+#include <arpa/nameser.h>
+]],
+[[int x = NXDOMAIN]])],
+AC_MSG_RESULT(no),
+AC_MSG_RESULT(yes)
+[BIND8_CFLAGS=-DBIND_8_COMPAT])
+AC_SUBST(BIND8_CFLAGS)
+
AST_C_DEFINE_CHECK([GLOB_NOMAGIC], [GLOB_NOMAGIC], [glob.h])
AST_C_DEFINE_CHECK([GLOB_BRACE], [GLOB_BRACE], [glob.h])
diff --git a/include/asterisk/res_pjsip_session.h b/include/asterisk/res_pjsip_session.h
index 10e55f133..e2a90662e 100644
--- a/include/asterisk/res_pjsip_session.h
+++ b/include/asterisk/res_pjsip_session.h
@@ -155,6 +155,10 @@ struct ast_sip_session {
struct ast_sip_aor *aor;
/*! From header saved at invite creation */
pjsip_fromto_hdr *saved_from_hdr;
+ /*! Whether the end of the session should be deferred */
+ unsigned int defer_end:1;
+ /*! Session end (remote hangup) requested while termination deferred */
+ unsigned int ended_while_deferred:1;
};
typedef int (*ast_sip_session_request_creation_cb)(struct ast_sip_session *session, pjsip_tx_data *tdata);
@@ -484,6 +488,13 @@ int ast_sip_session_defer_termination(struct ast_sip_session *session);
void ast_sip_session_defer_termination_cancel(struct ast_sip_session *session);
/*!
+ * \brief End the session if it had been previously deferred
+ *
+ * \param session The session to end if it had been deferred
+ */
+void ast_sip_session_end_if_deferred(struct ast_sip_session *session);
+
+/*!
* \brief Register an SDP handler
*
* An SDP handler is responsible for parsing incoming SDP streams and ensuring that
diff --git a/makeopts.in b/makeopts.in
index 03ef7470c..07360a71b 100644
--- a/makeopts.in
+++ b/makeopts.in
@@ -62,6 +62,8 @@ HOST_OS=@HOST_OS@
OSARCH=@OSARCH@
OSREV=@PBX_OSREV@
+BIND8_CFLAGS=@BIND8_CFLAGS@
+
PTHREAD_CFLAGS=@PTHREAD_CFLAGS@
PTHREAD_LIBS=@PTHREAD_LIBS@
diff --git a/res/res_pjsip_mwi.c b/res/res_pjsip_mwi.c
index e625df77a..3dfccef86 100644
--- a/res/res_pjsip_mwi.c
+++ b/res/res_pjsip_mwi.c
@@ -1278,7 +1278,9 @@ static struct ast_sorcery_observer global_observer = {
static int reload(void)
{
- create_mwi_subscriptions();
+ if (!ast_sip_get_mwi_disable_initial_unsolicited()) {
+ create_mwi_subscriptions();
+ }
return 0;
}
@@ -1301,13 +1303,13 @@ static int load_module(void)
ast_sip_unregister_subscription_handler(&mwi_handler);
return AST_MODULE_LOAD_DECLINE;
}
- create_mwi_subscriptions();
ast_sorcery_observer_add(ast_sip_get_sorcery(), "contact", &mwi_contact_observer);
ast_sorcery_observer_add(ast_sip_get_sorcery(), "global", &global_observer);
ast_sorcery_reload_object(ast_sip_get_sorcery(), "global");
if (!ast_sip_get_mwi_disable_initial_unsolicited()) {
+ create_mwi_subscriptions();
if (ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
ast_sip_push_task(NULL, send_initial_notify_all, NULL);
} else {
diff --git a/res/res_pjsip_refer.c b/res/res_pjsip_refer.c
index 46295387d..456e09dd8 100644
--- a/res/res_pjsip_refer.c
+++ b/res/res_pjsip_refer.c
@@ -543,6 +543,7 @@ static int refer_attended_task(void *data)
}
}
+ ast_sip_session_end_if_deferred(attended->transferer);
if (response != 200) {
if (!ast_sip_push_task(attended->transferer->serializer,
defer_termination_cancel, attended->transferer)) {
@@ -772,6 +773,7 @@ static int refer_incoming_attended_request(struct ast_sip_session *session, pjsi
/* Push it to the other session, which will have both channels with minimal locking */
if (ast_sip_push_task(other_session->serializer, refer_attended_task, attended)) {
+ ast_sip_session_end_if_deferred(session);
ast_sip_session_defer_termination_cancel(session);
ao2_cleanup(attended);
return 500;
@@ -810,9 +812,12 @@ static int refer_incoming_attended_request(struct ast_sip_session *session, pjsi
response = xfer_response_code2sip(ast_bridge_transfer_blind(1, session->channel,
"external_replaces", context, refer_blind_callback, &refer));
+
+ ast_sip_session_end_if_deferred(session);
if (response != 200) {
ast_sip_session_defer_termination_cancel(session);
}
+
return response;
}
}
@@ -865,9 +870,12 @@ static int refer_incoming_blind_request(struct ast_sip_session *session, pjsip_r
response = xfer_response_code2sip(ast_bridge_transfer_blind(1, session->channel,
exten, context, refer_blind_callback, &refer));
+
+ ast_sip_session_end_if_deferred(session);
if (response != 200) {
ast_sip_session_defer_termination_cancel(session);
}
+
return response;
}
diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index 8447be36e..ffd01cadf 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -1905,6 +1905,9 @@ int ast_sip_session_defer_termination(struct ast_sip_session *session)
session->defer_terminate = 1;
+ session->defer_end = 1;
+ session->ended_while_deferred = 0;
+
session->scheduled_termination.id = 0;
ao2_ref(session, +1);
session->scheduled_termination.user_data = session;
@@ -1942,6 +1945,7 @@ void ast_sip_session_defer_termination_cancel(struct ast_sip_session *session)
/* Already canceled or timer fired. */
return;
}
+
session->defer_terminate = 0;
if (session->terminate_while_deferred) {
@@ -1953,6 +1957,22 @@ void ast_sip_session_defer_termination_cancel(struct ast_sip_session *session)
sip_session_defer_termination_stop_timer(session);
}
+void ast_sip_session_end_if_deferred(struct ast_sip_session *session)
+{
+ if (!session->defer_end) {
+ return;
+ }
+
+ session->defer_end = 0;
+
+ if (session->ended_while_deferred) {
+ /* Complete the session end started by the remote hangup. */
+ ast_debug(3, "Ending session (%p) after being deferred\n", session);
+ session->ended_while_deferred = 0;
+ session_end(session);
+ }
+}
+
struct ast_sip_session *ast_sip_dialog_get_session(pjsip_dialog *dlg)
{
pjsip_inv_session *inv_session = pjsip_dlg_get_inv_session(dlg);
@@ -2672,6 +2692,12 @@ static void session_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e)
}
if (inv->state == PJSIP_INV_STATE_DISCONNECTED) {
+ if (session->defer_end) {
+ ast_debug(3, "Deferring session (%p) end\n", session);
+ session->ended_while_deferred = 1;
+ return;
+ }
+
if (ast_sip_push_task(session->serializer, session_end, session)) {
/* Do it anyway even though this is not the right thread. */
session_end(session);
@@ -3159,8 +3185,7 @@ static void session_outgoing_nat_hook(pjsip_tx_data *tdata, struct ast_sip_trans
ast_sockaddr_parse(&addr, host, PARSE_PORT_FORBID);
if (!transport_state->localnet
- || (transport_state->localnet
- && ast_apply_ha(transport_state->localnet, &addr) == AST_SENSE_ALLOW)) {
+ || ast_apply_ha(transport_state->localnet, &addr) != AST_SENSE_ALLOW) {
ast_debug(5, "Setting external media address to %s\n", transport->external_media_address);
pj_strdup2(tdata->pool, &sdp->conn->addr, transport->external_media_address);
}
diff --git a/res/res_pjsip_session.exports.in b/res/res_pjsip_session.exports.in
index a39485e66..fdfc5fb47 100644
--- a/res/res_pjsip_session.exports.in
+++ b/res/res_pjsip_session.exports.in
@@ -3,6 +3,7 @@
LINKER_SYMBOL_PREFIXast_sip_session_terminate;
LINKER_SYMBOL_PREFIXast_sip_session_defer_termination;
LINKER_SYMBOL_PREFIXast_sip_session_defer_termination_cancel;
+ LINKER_SYMBOL_PREFIXast_sip_session_end_if_deferred;
LINKER_SYMBOL_PREFIXast_sip_session_register_sdp_handler;
LINKER_SYMBOL_PREFIXast_sip_session_unregister_sdp_handler;
LINKER_SYMBOL_PREFIXast_sip_session_register_supplement;
diff --git a/res/res_pjsip_transport_websocket.c b/res/res_pjsip_transport_websocket.c
index b3e63fcc1..cdda8c196 100644
--- a/res/res_pjsip_transport_websocket.c
+++ b/res/res_pjsip_transport_websocket.c
@@ -302,10 +302,14 @@ static int get_write_timeout(void)
for (; (transport_state = ao2_iterator_next(&it_transport_states)); ao2_cleanup(transport_state)) {
struct ast_sip_transport *transport;
+
if (transport_state->type != AST_TRANSPORT_WS && transport_state->type != AST_TRANSPORT_WSS) {
continue;
}
transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_state->id);
+ if (!transport) {
+ continue;
+ }
ast_debug(5, "Found %s transport with write timeout: %d\n",
transport->type == AST_TRANSPORT_WS ? "WS" : "WSS",
transport->write_timeout);
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index c120fc145..600846c85 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -3447,7 +3447,7 @@ static void ast_rtp_change_source(struct ast_rtp_instance *instance)
ast_debug(3, "Changing ssrc for SRTP from %u to %u\n", rtp->ssrc, ssrc);
res_srtp->change_source(srtp, rtp->ssrc, ssrc);
if (rtcp_srtp != srtp) {
- res_srtp->change_source(srtp, rtp->ssrc, ssrc);
+ res_srtp->change_source(rtcp_srtp, rtp->ssrc, ssrc);
}
}
diff --git a/third-party/pjproject/Makefile b/third-party/pjproject/Makefile
index e691f2242..a5b550842 100644
--- a/third-party/pjproject/Makefile
+++ b/third-party/pjproject/Makefile
@@ -97,7 +97,7 @@ endef
define download_from_pjproject
($(SHELL_ECHO_PREFIX) Downloading $(TARBALL_URL) to $(TARBALL) ;\
$(DOWNLOAD_TO_STDOUT) $(call DOWNLOAD_TIMEOUT,5,60) $(TARBALL_URL) > $(TARBALL) &&\
- $(SHELL_ECHO_PREFIX) Downloading $(PJPROJECT_URL)/MD5SUM to $(PJMD5SUM) &&\
+ $(SHELL_ECHO_PREFIX) Downloading $(PJPROJECT_URL)/MD5SUM.TXT to $(PJMD5SUM) &&\
$(DOWNLOAD_TO_STDOUT) $(call DOWNLOAD_TIMEOUT,5,60) $(PJPROJECT_URL)/MD5SUM.TXT > $(PJMD5SUM) &&\
$(verify_tarball))
endef
diff --git a/third-party/pjproject/Makefile.rules b/third-party/pjproject/Makefile.rules
index c0be1cbdf..3f99c8a8f 100644
--- a/third-party/pjproject/Makefile.rules
+++ b/third-party/pjproject/Makefile.rules
@@ -1,4 +1,4 @@
-PJPROJECT_URL = http://www.pjsip.org/release/$(PJPROJECT_VERSION)
+PJPROJECT_URL ?= https://raw.githubusercontent.com/asterisk/third-party/master/pjproject/$(PJPROJECT_VERSION)
# Even though we're not installing pjproject, we're setting prefix to /opt/pjproject to be safe