[Asterisk-code-review] app_dial: Prevent call from hanging (asterisk[master])

N A asteriskteam at digium.com
Wed Jun 2 10:29:21 CDT 2021


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15985 )


Change subject: app_dial: Prevent call from hanging
......................................................................

app_dial: Prevent call from hanging

Addresses the scenario where DTMF is
sent upon a Progress event but the called
channel hangs up abruptly while this is
ongoing, in which case the call is abandoned
rather than held in an infinite loop.

ASTERISK-29428

Change-Id: I6f2ee3f77b892015bc05513d868f071f279a3c80
---
M apps/app_dial.c
1 file changed, 9 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/85/15985/1

diff --git a/apps/app_dial.c b/apps/app_dial.c
index d611083..c3055b5 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -1223,6 +1223,7 @@
 	int num_ringing = 0;
 	int sent_ring = 0;
 	int sent_progress = 0;
+	int failed_frame_forwards = 0;
 	struct timeval start = ast_tvnow();
 	SCOPE_ENTER(3, "%s\n", ast_channel_name(in));
 
@@ -1797,6 +1798,13 @@
 					if (ast_write(o->chan, f)) {
 						ast_log(LOG_WARNING, "Unable to forward frametype: %u\n",
 							f->frametype);
+						/* If we're trying to send DTMF and the call has hung up
+						before we could finish, we're stuck in a loop. Abandon call. */
+						if (sent_progress == 1 && ++failed_frame_forwards > 100) {
+							ast_log(LOG_WARNING, "Failed to send Progress DTMF. Abandoning call.\n");
+							ast_frfree(f);
+							goto wait_over;
+						}
 					}
 					break;
 				case AST_FRAME_CONTROL:
@@ -1858,7 +1866,7 @@
 			ast_frfree(f);
 		}
 	}
-
+wait_over:;
 	if (!*to || ast_check_hangup(in)) {
 		ast_verb(3, "Nobody picked up in %d ms\n", orig);
 		publish_dial_end_event(in, out_chans, NULL, "NOANSWER");

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15985
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I6f2ee3f77b892015bc05513d868f071f279a3c80
Gerrit-Change-Number: 15985
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210602/84470b22/attachment.html>


More information about the asterisk-code-review mailing list