[Asterisk-code-review] res_pjsip_refer: Always serialize calls to refer_progress_notify (asterisk[master])
George Joseph
asteriskteam at digium.com
Thu Feb 11 09:09:31 CST 2021
George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15424 )
Change subject: res_pjsip_refer: Always serialize calls to refer_progress_notify
......................................................................
res_pjsip_refer: Always serialize calls to refer_progress_notify
refer_progress_notify wasn't always being called from the progress
serializer. This could allow clearing notification->progress->sub
in one thread while another was trying to use it.
* Instances where refer_progress_notify was being called in-line,
have been changed to use ast_sip_push_task().
Change-Id: Idcf1934c4e873f2c82e2d106f8d9f040caf9fa1e
---
M res/res_pjsip_refer.c
1 file changed, 26 insertions(+), 10 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/24/15424/1
diff --git a/res/res_pjsip_refer.c b/res/res_pjsip_refer.c
index 06ea0b6..17625cc 100644
--- a/res/res_pjsip_refer.c
+++ b/res/res_pjsip_refer.c
@@ -127,10 +127,14 @@
* but we are already running a task... thus it would deadlock */
if (notification->state == PJSIP_EVSUB_STATE_TERMINATED) {
ast_debug(3, "Subscription '%p' is being terminated as a result of a NOTIFY, removing REFER progress structure early on progress monitor '%p'\n",
- notification->progress->sub, notification->progress);
- pjsip_dlg_inc_lock(notification->progress->dlg);
- pjsip_evsub_set_mod_data(notification->progress->sub, refer_progress_module.id, NULL);
- pjsip_dlg_dec_lock(notification->progress->dlg);
+ sub, notification->progress);
+ if (!notification->progress->sub) {
+ ast_log(LOG_WARNING, "Subscription %p was stepped on!", sub);
+ } else {
+ pjsip_dlg_inc_lock(notification->progress->dlg);
+ pjsip_evsub_set_mod_data(notification->progress->sub, refer_progress_module.id, NULL);
+ pjsip_dlg_dec_lock(notification->progress->dlg);
+ }
/* This is for dropping the reference on the subscription */
ao2_cleanup(notification->progress);
@@ -560,7 +564,9 @@
notification = refer_progress_notification_alloc(attended->progress, response,
PJSIP_EVSUB_STATE_TERMINATED);
if (notification) {
- refer_progress_notify(notification);
+ if (ast_sip_push_task(attended->progress->serializer, refer_progress_notify, notification)) {
+ ao2_cleanup(notification);
+ }
}
}
@@ -616,7 +622,9 @@
PJSIP_EVSUB_STATE_TERMINATED);
if (notification) {
- refer_progress_notify(notification);
+ if (ast_sip_push_task(refer->progress->serializer, refer_progress_notify, notification)) {
+ ao2_cleanup(notification);
+ }
}
} else if (refer->progress) {
/* If attended transfer and progress monitoring is being done attach a frame hook so we can monitor it */
@@ -637,7 +645,9 @@
ast_channel_name(chan));
if (notification) {
- refer_progress_notify(notification);
+ if (ast_sip_push_task(refer->progress->serializer, refer_progress_notify, notification)) {
+ ao2_cleanup(notification);
+ }
}
}
@@ -660,7 +670,9 @@
ast_channel_name(chan));
if (notification) {
- refer_progress_notify(notification);
+ if (ast_sip_push_task(refer->progress->serializer, refer_progress_notify, notification)) {
+ ao2_cleanup(notification);
+ }
}
ao2_cleanup(refer->progress);
@@ -680,7 +692,9 @@
ast_channel_name(chan));
if (notification) {
- refer_progress_notify(notification);
+ if (ast_sip_push_task(refer->progress->serializer, refer_progress_notify, notification)) {
+ ao2_cleanup(notification);
+ }
}
ast_channel_lock(chan);
@@ -1155,7 +1169,9 @@
if (notification) {
/* The refer_progress_notify function will call ao2_cleanup on this for us */
- refer_progress_notify(notification);
+ if (ast_sip_push_task(progress->serializer, refer_progress_notify, notification)) {
+ ao2_cleanup(notification);
+ }
}
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15424
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Idcf1934c4e873f2c82e2d106f8d9f040caf9fa1e
Gerrit-Change-Number: 15424
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210211/6ddcc04c/attachment.html>
More information about the asterisk-code-review
mailing list