From: Tinet-mucw Date: Thu, 19 Jun 2025 02:34:56 +0000 (-0700) Subject: pbx.c: when set flag AST_SOFTHANGUP_ASYNCGOTO, ast_explicit_goto should return -1. X-Git-Tag: 20.16.0-rc1~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3b9d5a00e43985b316046b04e7a62bd110e0c6e2;p=thirdparty%2Fasterisk.git pbx.c: when set flag AST_SOFTHANGUP_ASYNCGOTO, ast_explicit_goto should return -1. Under certain circumstances the context/extens/prio are set in the ast_async_goto, for example action Redirect. In the situation that action Redirect is broken by GotoIf this info is changed. that will causes confusion in dialplan execution. Resolves: #1273 (cherry picked from commit 88f653c12df8cc7b82cdfb53fb38524a6840e518) --- diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h index c307254fa3..9fff731048 100644 --- a/include/asterisk/pbx.h +++ b/include/asterisk/pbx.h @@ -1152,6 +1152,8 @@ int ast_context_unlockmacro(const char *macrocontext); * \brief Set the channel to next execute the specified dialplan location. * \see ast_async_parseable_goto, ast_async_goto_if_exists * + * \note If the AST_SOFTHANGUP_ASYNCGOTO flag is set, + * it can prevent the dialplan location from being overwritten by ast_explicit_goto. * \note Do _NOT_ hold any channel locks when calling this function. */ int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority); @@ -1533,6 +1535,7 @@ int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string); /*! * \note This function will handle locking the channel as needed. + * \note If the AST_SOFTHANGUP_ASYNCGOTO flag is set on the channel, this function will fail and return -1. */ int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority); diff --git a/main/pbx.c b/main/pbx.c index 4d9ad17c17..b797000bdb 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -7009,6 +7009,10 @@ int ast_explicit_goto(struct ast_channel *chan, const char *context, const char ast_channel_lock(chan); + if (ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_ASYNCGOTO) { + ast_channel_unlock(chan); + return -1; + } if (!ast_strlen_zero(context)) ast_channel_context_set(chan, context); if (!ast_strlen_zero(exten))