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

Frederic LE FOLL asteriskteam at digium.com
Wed Oct 26 08:00:35 CDT 2022


Frederic LE FOLL has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19489 )


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(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/89/19489/1

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Idbdd5c15122159661aa8e996a42d5800083131e4
Gerrit-Change-Number: 19489
Gerrit-PatchSet: 1
Gerrit-Owner: Frederic LE FOLL <frederic.lefoll at csgroup.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221026/ee35b1ca/attachment.html>


More information about the asterisk-code-review mailing list