From a7280b6114ee8a1b209b657806889100b2c80bd7 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Wed, 30 Jan 2019 11:16:56 +0100 Subject: [PATCH 1/3] pjproject: add patches from asterisk's bundled pjproject "check whether UPDATE is supported on outgoing calls", commit 5de36abd: In ASTERISK-27095 an issue had been fixed because of which chan_pjsip was not trying to send UPDATE messages when connected_line_method was set to invite. However this only solved the issue for incoming INVITES. For outgoing INVITES (important when transferring calls) the options variable needs to be updated at a different place. "Add patch for double free issue in timer heap", commit 9c11399b: Fixed #2172: Avoid double reference counter decrements in timer in the scenario of race condition between pj_timer_heap_cancel() and pj_timer_heap_poll(). "Add timer patch from pjproject r5934", commit d4cd2a97. Signed-off-by: Andre Heider --- libs/pjproject/Makefile | 2 +- ...utgoing_connected_line_method_update.patch | 32 ++++++++++++++++ ...-double-reference-counter-decrements.patch | 37 +++++++++++++++++++ ...pop_freelist-push_freelist-after-rem.patch | 32 ++++++++++++++++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 libs/pjproject/patches/210-outgoing_connected_line_method_update.patch create mode 100644 libs/pjproject/patches/220-Fixed-2172-Avoid-double-reference-counter-decrements.patch create mode 100644 libs/pjproject/patches/230-Re-2176-Removed-pop_freelist-push_freelist-after-rem.patch diff --git a/libs/pjproject/Makefile b/libs/pjproject/Makefile index 2b9da08..69c0fa4 100644 --- a/libs/pjproject/Makefile +++ b/libs/pjproject/Makefile @@ -11,7 +11,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=pjproject PKG_VERSION:=2.8 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=pjproject-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=http://www.pjsip.org/release/$(PKG_VERSION) diff --git a/libs/pjproject/patches/210-outgoing_connected_line_method_update.patch b/libs/pjproject/patches/210-outgoing_connected_line_method_update.patch new file mode 100644 index 0000000..201bc3e --- /dev/null +++ b/libs/pjproject/patches/210-outgoing_connected_line_method_update.patch @@ -0,0 +1,32 @@ +--- a/pjsip/src/pjsip-ua/sip_inv.c ++++ b/pjsip/src/pjsip-ua/sip_inv.c +@@ -4185,6 +4185,29 @@ static void inv_on_state_calling( pjsip_ + + if (tsx->status_code != 100) { + ++ if (inv->role == PJSIP_ROLE_UAC) { ++ pjsip_rx_data *rdata = e->body.tsx_state.src.rdata; ++ pjsip_allow_hdr *allow = NULL; ++ pjsip_msg *msg = rdata->msg_info.msg; ++ ++ if (msg) { ++ allow = (pjsip_allow_hdr*) pjsip_msg_find_hdr(msg, PJSIP_H_ALLOW, ++ NULL); ++ } ++ if (allow) { ++ unsigned i; ++ const pj_str_t STR_UPDATE = { "UPDATE", 6 }; ++ ++ for (i=0; icount; ++i) { ++ if (pj_stricmp(&allow->values[i], &STR_UPDATE)==0) { ++ /* UPDATE is present in Allow */ ++ inv->options |= PJSIP_INV_SUPPORT_UPDATE; ++ break; ++ } ++ } ++ } ++ } ++ + if (dlg->remote.info->tag.slen) + inv_set_state(inv, PJSIP_INV_STATE_EARLY, e); + diff --git a/libs/pjproject/patches/220-Fixed-2172-Avoid-double-reference-counter-decrements.patch b/libs/pjproject/patches/220-Fixed-2172-Avoid-double-reference-counter-decrements.patch new file mode 100644 index 0000000..02634a5 --- /dev/null +++ b/libs/pjproject/patches/220-Fixed-2172-Avoid-double-reference-counter-decrements.patch @@ -0,0 +1,37 @@ +From 1fed39fe1488abd654a5488b5e6ad59b4b973331 Mon Sep 17 00:00:00 2001 +From: nanang +Date: Tue, 8 Jan 2019 09:07:47 +0000 +Subject: [PATCH 1/5] Fixed #2172: Avoid double reference counter decrements in + timer in the scenario of race condition between pj_timer_heap_cancel() and + pj_timer_heap_poll(). + +--- + pjlib/src/pj/timer.c | 17 ++++++++++------- + 1 file changed, 10 insertions(+), 7 deletions(-) + +--- a/pjlib/src/pj/timer.c ++++ b/pjlib/src/pj/timer.c +@@ -580,13 +580,16 @@ static int cancel_timer(pj_timer_heap_t + + lock_timer_heap(ht); + count = cancel(ht, entry, flags | F_DONT_CALL); +- if (flags & F_SET_ID) { +- entry->id = id_val; +- } +- if (entry->_grp_lock) { +- pj_grp_lock_t *grp_lock = entry->_grp_lock; +- entry->_grp_lock = NULL; +- pj_grp_lock_dec_ref(grp_lock); ++ if (count > 0) { ++ /* Timer entry found & cancelled */ ++ if (flags & F_SET_ID) { ++ entry->id = id_val; ++ } ++ if (entry->_grp_lock) { ++ pj_grp_lock_t *grp_lock = entry->_grp_lock; ++ entry->_grp_lock = NULL; ++ pj_grp_lock_dec_ref(grp_lock); ++ } + } + unlock_timer_heap(ht); + diff --git a/libs/pjproject/patches/230-Re-2176-Removed-pop_freelist-push_freelist-after-rem.patch b/libs/pjproject/patches/230-Re-2176-Removed-pop_freelist-push_freelist-after-rem.patch new file mode 100644 index 0000000..d0b60e6 --- /dev/null +++ b/libs/pjproject/patches/230-Re-2176-Removed-pop_freelist-push_freelist-after-rem.patch @@ -0,0 +1,32 @@ +From 9f57a5728aaec1949908bf7bbd15768fce74e315 Mon Sep 17 00:00:00 2001 +From: Nanang Izzuddin +Date: Wed, 13 Feb 2019 06:51:09 +0000 +Subject: [PATCH] Re #2176: Removed pop_freelist() + push_freelist() after + remove_node() as they are not only unnecessary, they cause problem. + +git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@5934 74dad513-b988-da41-8d7b-12977e46ad98 +--- + pjlib/src/pj/timer.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/pjlib/src/pj/timer.c ++++ b/pjlib/src/pj/timer.c +@@ -633,7 +633,8 @@ PJ_DEF(unsigned) pj_timer_heap_poll( pj_ + { + pj_timer_entry *node = remove_node(ht, 0); + /* Avoid re-use of this timer until the callback is done. */ +- pj_timer_id_t node_timer_id = pop_freelist(ht); ++ ///Not necessary, even causes problem (see also #2176). ++ ///pj_timer_id_t node_timer_id = pop_freelist(ht); + pj_grp_lock_t *grp_lock; + + ++count; +@@ -653,7 +654,7 @@ PJ_DEF(unsigned) pj_timer_heap_poll( pj_ + + lock_timer_heap(ht); + /* Now, the timer is really free for re-use. */ +- push_freelist(ht, node_timer_id); ++ ///push_freelist(ht, node_timer_id); + } + if (ht->cur_size && next_delay) { + *next_delay = ht->heap[0]->_timer_value; From 2a87b37fb36aa6ecc833f4080cced064dda0abdc Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Fri, 12 Oct 2018 12:41:45 +0200 Subject: [PATCH 2/3] asterisk-g72x: add variant for asterisk 16 Signed-off-by: Andre Heider --- net/asterisk-g72x/Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/net/asterisk-g72x/Makefile b/net/asterisk-g72x/Makefile index dc0c7f3..78d9fbd 100644 --- a/net/asterisk-g72x/Makefile +++ b/net/asterisk-g72x/Makefile @@ -48,12 +48,19 @@ $(call Package/asterisk-g72x/Default) VARIANT:=asterisk15 endef +define Package/asterisk16-codec-g729 +$(call Package/asterisk-g72x/Default) + DEPENDS+=asterisk16 + VARIANT:=asterisk16 +endef + define Package/description/Default Asterisk G.729 codec based on bcg729 implementation. endef Package/asterisk13-codec-g729/description = $(Package/description/Default) Package/asterisk15-codec-g729/description = $(Package/description/Default) +Package/asterisk16-codec-g729/description = $(Package/description/Default) CONFIGURE_ARGS+= \ --with-bcg729 \ @@ -71,6 +78,12 @@ CONFIGURE_ARGS+= \ --with-asterisk150 endif +ifeq ($(BUILD_VARIANT),asterisk16) +CONFIGURE_ARGS+= \ + --with-asterisk-includes=$(STAGING_DIR)/usr/include/asterisk-16/include \ + --with-asterisk160 +endif + define Package/Install/Default $(INSTALL_DIR) $(1)/usr/lib/asterisk/modules $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/codec_g729.so \ @@ -79,6 +92,8 @@ endef Package/asterisk13-codec-g729/install = $(Package/Install/Default) Package/asterisk15-codec-g729/install = $(Package/Install/Default) +Package/asterisk16-codec-g729/install = $(Package/Install/Default) $(eval $(call BuildPackage,asterisk13-codec-g729)) $(eval $(call BuildPackage,asterisk15-codec-g729)) +$(eval $(call BuildPackage,asterisk16-codec-g729)) From a669566e1be0676c2fb9f505d58c2ea714623459 Mon Sep 17 00:00:00 2001 From: Andre Heider Date: Fri, 12 Oct 2018 12:41:59 +0200 Subject: [PATCH 3/3] asterisk-opus: add variant for asterisk 16 Signed-off-by: Andre Heider --- net/asterisk-opus/Makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/asterisk-opus/Makefile b/net/asterisk-opus/Makefile index 36f4abd..f357ab1 100644 --- a/net/asterisk-opus/Makefile +++ b/net/asterisk-opus/Makefile @@ -53,6 +53,12 @@ $(call Package/$(PKG_NAME)/Default) VARIANT:=asterisk15 endef +define Package/asterisk16-codec-opus +$(call Package/$(PKG_NAME)/Default) + DEPENDS+=asterisk16 + VARIANT:=asterisk16 +endef + define Package/description/Default Opus is the default audio codec in WebRTC. WebRTC is available in Asterisk via SIP over WebSockets (WSS). Nevertheless, Opus can be used @@ -69,6 +75,7 @@ endef Package/asterisk13-codec-opus/description = $(Package/description/Default) Package/asterisk15-codec-opus/description = $(Package/description/Default) +Package/asterisk16-codec-opus/description = $(Package/description/Default) ifeq ($(BUILD_VARIANT),asterisk13) TARGET_CFLAGS+=-I$(STAGING_DIR)/usr/include/asterisk-13/include @@ -78,6 +85,10 @@ ifeq ($(BUILD_VARIANT),asterisk15) TARGET_CFLAGS+=-I$(STAGING_DIR)/usr/include/asterisk-15/include endif +ifeq ($(BUILD_VARIANT),asterisk16) +TARGET_CFLAGS+=-I$(STAGING_DIR)/usr/include/asterisk-16/include +endif + define Package/Install/Default $(INSTALL_DIR) $(1)/usr/lib/asterisk/modules $(INSTALL_BIN) $(PKG_BUILD_DIR)/codecs/codec_opus_open_source.so \ @@ -86,9 +97,11 @@ endef Package/asterisk13-codec-opus/install = $(Package/Install/Default) Package/asterisk15-codec-opus/install = $(Package/Install/Default) +Package/asterisk16-codec-opus/install = $(Package/Install/Default) define Build/Configure endef $(eval $(call BuildPackage,asterisk13-codec-opus)) $(eval $(call BuildPackage,asterisk15-codec-opus)) +$(eval $(call BuildPackage,asterisk16-codec-opus))