Skip to content

Commit 4913bf7

Browse files
committed
app_record: Fix BYE handling before record loop
When a BYE is received while app_record is playing the initial beep (or immediately after it), but before entering the main recording loop, the application does not detect the hangup and continues running until timeout. This change adds an early hangup check before the ast_waitfor() loop to ensure the application exits immediately when the channel is already in a hung-up state.
1 parent 8fda0ab commit 4913bf7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

apps/app_record.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,12 @@ static int record_exec(struct ast_channel *chan, const char *data)
511511
if (maxduration <= 0)
512512
maxduration = -1;
513513

514+
if (ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
515+
ast_debug(1, "Channel hangup detected before ast_waitfor().\n");
516+
status_response = "HANGUP";
517+
res = -1;
518+
goto out;
519+
}
514520
start = ast_tvnow();
515521
while ((ms = ast_remaining_ms(start, maxduration))) {
516522
ms = ast_waitfor(chan, ms);

0 commit comments

Comments
 (0)