[Asterisk-code-review] res_pjsip_pubsub: destroy old subscriptions on RLS update using seria... (asterisk[16])
Alexei Gradinari
asteriskteam at digium.com
Wed Aug 3 10:16:30 CDT 2022
Alexei Gradinari has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18891 )
Change subject: res_pjsip_pubsub: destroy old subscriptions on RLS update using serializer
......................................................................
res_pjsip_pubsub: destroy old subscriptions on RLS update using serializer
Set termination state to old subscriptions to immediately stop
sending NOTIFY messages on exten/device state changes.
Fix a data-race on RLS update.
While destroyinng old subscriptions, they can be used by exten/device state
changes. Thus, we need to add a task into serializer of subscription tree
to destroy old subscriptions.
ASTERISK-29906
Change-Id: I96582aad3a26515ca73a8460ee6756f56f6ba23b
---
M res/res_pjsip_pubsub.c
1 file changed, 20 insertions(+), 2 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/91/18891/1
diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c
index d0f3717..cd7724b 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -3994,6 +3994,16 @@
return 0;
}
+static int destroy_subscriptions_task(void *obj)
+{
+ struct ast_sip_subscription *sub = (struct ast_sip_subscription *) obj;
+
+ shutdown_subscriptions(sub);
+ destroy_subscriptions(sub);
+
+ return 0;
+}
+
/*!
* \brief Called whenever an in-dialog SUBSCRIBE is received
*
@@ -4067,8 +4077,16 @@
AST_SCHED_DEL_UNREF(sched, sub_tree->notify_sched_id, ao2_ref(sub_tree, -1));
sub_tree->send_scheduled_notify = 0;
}
- shutdown_subscriptions(old_root);
- destroy_subscriptions(old_root);
+
+ /* Terminate old subscriptions to stop sending NOTIFY messages on exten/device state changes */
+ set_state_terminated(old_root);
+
+ if (ast_sip_push_task(sub_tree->serializer, destroy_subscriptions_task, old_root)) {
+ ast_log(LOG_ERROR, "Failed to push task to destroy old subscriptions for RLS '%s->%s'.\n",
+ ast_sorcery_object_get_id(endpoint), old_root->resource);
+ /* If we can't push the destroy task, then just shutdown old subscriptions */
+ shutdown_subscriptions(old_root);
+ }
} else {
destroy_subscriptions(new_root);
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18891
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I96582aad3a26515ca73a8460ee6756f56f6ba23b
Gerrit-Change-Number: 18891
Gerrit-PatchSet: 1
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220803/1f3ceb1d/attachment.html>
More information about the asterisk-code-review
mailing list