app_amd: Fix infinite loop on silent calls
authoragupta <abhay@avissol.com>
Tue, 4 Dec 2018 08:10:15 +0000 (13:40 +0530)
committerJoshua Colp <jcolp@digium.com>
Tue, 30 Apr 2019 10:15:46 +0000 (04:15 -0600)
The total time logic will now be executed on calls which
do not pass any media.

ASTERISK-28143

Change-Id: I24726bd29d7e467fc721ca265363417234b22855

apps/app_amd.c

index 3f805bb..5285287 100644 (file)
@@ -280,7 +280,7 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
                int ms = 0;
 
                /* Figure out how long we waited */
-               if (res > 0) {
+               if (res >= 0) {
                        ms = 2 * maxWaitTimeForFrame - res;
                }
 
@@ -410,6 +410,14 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
                                }
 
                        }
+               } else {
+                       iTotalTime += ms;
+                       if (iTotalTime >= totalAnalysisTime) {
+                               ast_frfree(f);
+                               strcpy(amdStatus , "NOTSURE");
+                               sprintf(amdCause , "TOOLONG-%d", iTotalTime);
+                               break;
+                       }
                }
                ast_frfree(f);
        }