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

Friendly Automation asteriskteam at digium.com
Wed Oct 26 11:21:33 CDT 2022


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/19487 )

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
  Friendly Automation: 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/+/19487
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 19
Gerrit-Change-Id: Idbdd5c15122159661aa8e996a42d5800083131e4
Gerrit-Change-Number: 19487
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/20221026/5b682773/attachment.html>


More information about the asterisk-code-review mailing list