[Asterisk-code-review] res_pjsip_refer: Always serialize calls to refer_progress_notify (asterisk[master])

Friendly Automation asteriskteam at digium.com
Wed Feb 17 11:06:12 CST 2021


Friendly Automation has submitted this change. ( 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, 18 insertions(+), 6 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/res/res_pjsip_refer.c b/res/res_pjsip_refer.c
index 06ea0b6..030e2be 100644
--- a/res/res_pjsip_refer.c
+++ b/res/res_pjsip_refer.c
@@ -560,7 +560,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 +618,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 +641,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 +666,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 +688,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 +1165,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: 3
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210217/69a07d4e/attachment.html>


More information about the asterisk-code-review mailing list