[Asterisk-code-review] Dialing API: Cancel a running async thread, may not cancel all calls (asterisk[20])

George Joseph asteriskteam at digium.com
Thu Oct 27 07:52:13 CDT 2022


George Joseph has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/19488 )

Change subject: Dialing API: Cancel a running async thread, may not cancel all calls
......................................................................

Dialing API: Cancel a running async thread, may not cancel all calls

race condition: ast_dial_join() may not cancel outgoing call, if
function is called just after called party answer and before
application execution (bit is_running_app not yet set).

This fix adds ast_softhangup() calls in addition to existing
pthread_kill() when is_running_app is not set.

ASTERISK-30258

Change-Id: Idbdd5c15122159661aa8e996a42d5800083131e4
---
M main/dial.c
1 file changed, 27 insertions(+), 0 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved; Approved for Submit




diff --git a/main/dial.c b/main/dial.c
index 944207c..3906bd0 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -1043,8 +1043,17 @@
 			ast_channel_unlock(chan);
 		}
 	} else {
+		struct ast_dial_channel *channel = NULL;
+
 		/* Now we signal it with SIGURG so it will break out of it's waitfor */
 		pthread_kill(thread, SIGURG);
+
+		/* pthread_kill may not be enough, if outgoing channel has already got an answer (no more in waitfor) but is not yet running an application. Force soft hangup. */
+		AST_LIST_TRAVERSE(&dial->channels, channel, list) {
+			if (channel->owner) {
+				ast_softhangup(channel->owner, AST_SOFTHANGUP_EXPLICIT);
+			}
+		}
 	}
 	AST_LIST_UNLOCK(&dial->channels);
 

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

Gerrit-Project: asterisk
Gerrit-Branch: 20
Gerrit-Change-Id: Idbdd5c15122159661aa8e996a42d5800083131e4
Gerrit-Change-Number: 19488
Gerrit-PatchSet: 2
Gerrit-Owner: Frederic LE FOLL <frederic.lefoll at csgroup.eu>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221027/e94ca69f/attachment.html>


More information about the asterisk-code-review mailing list