]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Dialing API: Cancel a running async thread, may not cancel all calls
authorFrederic LE FOLL <frederic.lefoll@c-s.fr>
Thu, 6 Oct 2022 16:51:36 +0000 (18:51 +0200)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Wed, 26 Oct 2022 16:21:33 +0000 (11:21 -0500)
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

index 944207c07475ad359fa5d22772cade32fbb937b9..3906bd06b966325ca7c984b2a9aa2dc7b001a964 100644 (file)
@@ -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);