]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
main/dial.c: Set channel hangup cause on timeout in handle_timeout_trip
authorsarangr7 <sarangraj@carestack.com>
Thu, 18 Dec 2025 06:04:14 +0000 (11:34 +0530)
committersarangr7 <sarangraj@carestack.com>
Mon, 29 Dec 2025 19:37:31 +0000 (19:37 +0000)
When dial attempts timeout in the core dialing API, the channel's hangup
cause was not being set before hanging up. Only the ast_dial_channel
structure's internal cause field was updated, but the actual ast_channel
hangup cause remained unset.

This resulted in incorrect or missing hangup cause information being
reported through CDRs, AMI events, and other mechanisms that read the
channel's hangup cause when dial timeouts occurred via applications
using the dialing API (FollowMe, Page, etc.).

The fix adds proper channel locking and sets AST_CAUSE_NO_ANSWER on
the channel before calling ast_hangup(), ensuring consistent hangup
cause reporting across all interfaces.

Resolves: #1660

main/dial.c

index 3906bd06b966325ca7c984b2a9aa2dc7b001a964..c84b297cd1bc4fff2c1b52fa81fbd0acfa77c75f 100644 (file)
@@ -733,6 +733,9 @@ static int handle_timeout_trip(struct ast_dial *dial, struct timeval start)
        /* Go through dropping out channels that have met their timeout */
        AST_LIST_TRAVERSE(&dial->channels, channel, list) {
                if (dial->state == AST_DIAL_RESULT_TIMEOUT || diff >= channel->timeout) {
+                       ast_channel_lock(channel->owner);
+                       ast_channel_hangupcause_set(channel->owner, AST_CAUSE_NO_ANSWER);
+                       ast_channel_unlock(channel->owner);
                        ast_hangup(channel->owner);
                        channel->cause = AST_CAUSE_NO_ANSWER;
                        channel->owner = NULL;