[Asterisk-code-review] res_pjsip_pubsub: Fix subscription shutdown regression. (asterisk[master])

N A asteriskteam at digium.com
Wed Mar 15 17:14:44 CDT 2023


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19973 )


Change subject: res_pjsip_pubsub: Fix subscription shutdown regression.
......................................................................

res_pjsip_pubsub: Fix subscription shutdown regression.

ASTERISK_30325 introduced a regression that results in
subscription shutdown callbacks no longer firing when
a subscription is terminated by an endpoint. This is
as a result of changes in res_pjsip_pubsub to change
how subscription cleanup occured.

However, the fix employed seems to be partial at best,
since this can result in the tree cleanup not happening
at all, leaving users unaware the subscription has gone away.

To fix this, a call to clean_sub_tree is made in pubsub_on_refresh_timeout
if HAVE_PJSIP_EVSUB_PENDING_NOTIFY is defined.

ASTERISK-30469 #close

Change-Id: I677ec5e9c14b36ebffbc2392a79ce4db95d6a3ec
---
M res/res_pjsip_pubsub.c
1 file changed, 34 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/73/19973/1

diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c
index bf07d5a..a21d14d 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -3853,6 +3853,8 @@
 	struct sip_subscription_tree *sub_tree;
 	sub_tree = pjsip_evsub_get_mod_data(evsub, pubsub_module.id);
 
+	ast_debug(3, "Cleaning subscription %p\n", evsub);
+
 	if (sub_tree->expiration_task) {
 		char task_name[256];
 
@@ -3920,7 +3922,6 @@
 	   is called before pubsub_on_rx_refresh and so must be cleaned there.*/
 	clean_sub_tree(evsub);
 #endif
-
 }
 
 static int pubsub_on_refresh_timeout(void *userdata)
@@ -3953,6 +3954,14 @@
 
 	send_notify(sub_tree, 1);
 
+#ifdef HAVE_PJSIP_EVSUB_PENDING_NOTIFY
+	/* For >= 2.13, clean_sub_tree is not called in pubsub_on_evsub_state */
+	if (sub_tree->state == SIP_SUB_TREE_TERMINATE_IN_PROGRESS) {
+		ast_debug(5, "Removing terminated subscription %p\n", sub_tree->evsub);
+		clean_sub_tree(sub_tree->evsub);
+	}
+#endif
+
 	ast_test_suite_event_notify(sub_tree->root->subscription_state == PJSIP_EVSUB_STATE_TERMINATED ?
 				"SUBSCRIPTION_TERMINATED" : "SUBSCRIPTION_REFRESHED",
 				"Resource: %s", sub_tree->root->resource);
@@ -4160,8 +4169,6 @@
 			clean_sub_tree(evsub);
 	}
 #endif
-
-
 }
 
 static void pubsub_on_rx_notify(pjsip_evsub *evsub, pjsip_rx_data *rdata, int *p_st_code,

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19973
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I677ec5e9c14b36ebffbc2392a79ce4db95d6a3ec
Gerrit-Change-Number: 19973
Gerrit-PatchSet: 1
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20230315/5eb05561/attachment.html>


More information about the asterisk-code-review mailing list