From: Frederic LE FOLL Date: Thu, 6 Oct 2022 16:51:36 +0000 (+0200) Subject: Dialing API: Cancel a running async thread, may not cancel all calls X-Git-Tag: 18.16.0-rc1~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8da870fe1e82889d556f47c97712f6fe5142a68a;p=thirdparty%2Fasterisk.git 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 --- 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);