res_pjsip_pubsub: Postpone destruction of old subscriptions on RLS update

Set termination state to old subscriptions to prevent queueing and sending
NOTIFY messages on exten/device state changes.

Postpone destruction of old subscriptions until all already queued tasks
that may be using old subscriptions have completed.

ASTERISK-29906

Change-Id: I96582aad3a26515ca73a8460ee6756f56f6ba23b
This commit is contained in:
Alexei Gradinari
2022-08-03 10:55:47 -04:00
committed by Friendly Automation
parent 7db21bb8ed
commit 8d57581c77
2 changed files with 30 additions and 2 deletions

View File

@@ -296,7 +296,8 @@ static int notify_task(void *obj)
.body_data = &task_data->exten_state_data,
};
/* Terminated subscriptions are no longer associated with a valid tree, and sending
/* The subscription was terminated while notify_task was in queue.
Terminated subscriptions are no longer associated with a valid tree, and sending
* NOTIFY messages on a subscription which has already been terminated won't work.
*/
if (ast_sip_subscription_is_terminated(task_data->exten_state_sub->sip_sub)) {
@@ -339,6 +340,13 @@ static int state_changed(const char *context, const char *exten,
struct notify_task_data *task_data;
struct exten_state_subscription *exten_state_sub = data;
/* Terminated subscriptions are no longer associated with a valid tree.
* Do not queue notify_task.
*/
if (ast_sip_subscription_is_terminated(exten_state_sub->sip_sub)) {
return 0;
}
if (!(task_data = alloc_notify_task_data(exten, exten_state_sub, info))) {
return -1;
}