From 50a4495799fd4e5f15da5695a034b05943858f02 Mon Sep 17 00:00:00 2001 From: Frederic LE FOLL Date: Thu, 6 Oct 2022 18:51:36 +0200 Subject: [PATCH] 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 --- main/dial.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main/dial.c b/main/dial.c index 944207c074..3906bd06b9 100644 --- a/main/dial.c +++ b/main/dial.c @@ -1043,8 +1043,17 @@ enum ast_dial_result ast_dial_join(struct ast_dial *dial) 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); -- 2.47.2