[Home]

Summary:ASTERISK-28143: app_amd: Infinite loop on silent calls
Reporter:Abhay Gupta (agupta)Labels:patch
Date Opened:2018-10-31 08:14:43Date Closed:2019-10-31 10:16:04
Priority:MajorRegression?
Status:Closed/CompleteComponents:Applications/app_amd
Versions:15.6.1 Frequency of
Occurrence
Frequent
Related
Issues:
is caused byASTERISK-27610 app_amd.so returning TOOLONG before reaching the timeout
is related toASTERISK-28608 app_amd: Use time calculation to calculate timeout
Environment:Ubuntu with asterisk Attachments:( 0) amd.patch
Description:On our production server , some of the calls never return from AMD application , from logs we could see that they have last gone into AMD() of dialplan and comes out only when the call is HANGUP .

The suggested patch is to remove that infinite loop and has been tested for last few months and have been working well .

Comments:By: Asterisk Team (asteriskteam) 2018-10-31 08:14:44.277-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Abhay Gupta (agupta) 2018-10-31 08:18:19.139-0500

In case res<0 for ast_waitfor that the else condition is handled with AST_FRAME_NULL

By: George Joseph (gjoseph) 2018-10-31 08:44:28.610-0500

Thanks for the contribution! If you'd like your contribution to be included faster, you should submit your patch for code review by the Asterisk Developer Community. To do so, please follow the Code Review [1] instructions on the wiki. Be sure to:
* Verify that your patch conforms to the Coding Guidelines [2]
* Review the Code Review Checklist [3] for common items reviewers will look for
* If necessary, provide tests for the Asterisk Test Suite that verify the correctness of your patch [4]

When ready, submit your patch and any tests to Gerrit [5] for code review.

Thanks!

[1] https://wiki.asterisk.org/wiki/display/AST/Code+Review
[2] https://wiki.asterisk.org/wiki/display/AST/Coding+Guidelines
[3] https://wiki.asterisk.org/wiki/display/AST/Code+Review+Checklist
[4] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Test+Suite+Documentation
[5] https://wiki.asterisk.org/wiki/display/AST/Gerrit+Usage


NOTE:  In any case, you'll need to sign a license agreement before your patch can be accepted.


By: Asterisk Team (asteriskteam) 2018-11-14 12:00:01.650-0600

Suspended due to lack of activity. This issue will be automatically re-opened if the reporter posts a comment. If you are not the reporter and would like this re-opened please create a new issue instead. If the new issue is related to this one a link will be created during the triage process. Further information on issue tracker usage can be found in the Asterisk Issue Guidlines [1].

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines

By: Abhay Gupta (agupta) 2018-11-26 04:51:44.835-0600

Got access to Gerrit and will push the code there for review

By: Asterisk Team (asteriskteam) 2018-11-26 04:51:45.064-0600

This issue has been reopened as a result of your commenting on it as the reporter. It will be triaged once again as applicable.

By: Abhay Gupta (agupta) 2018-11-26 06:14:11.508-0600

Added patch on Gerrit

By: Friendly Automation (friendly-automation) 2019-04-30 10:05:41.314-0500

Change 11317 merged by Friendly Automation:
app_amd: Fix infinite loop on silent calls

[https://gerrit.asterisk.org/c/asterisk/+/11317|https://gerrit.asterisk.org/c/asterisk/+/11317]

By: Friendly Automation (friendly-automation) 2019-04-30 10:05:56.380-0500

Change 10736 merged by Friendly Automation:
app_amd: Fix infinite loop on silent calls

[https://gerrit.asterisk.org/c/asterisk/+/10736|https://gerrit.asterisk.org/c/asterisk/+/10736]

By: Friendly Automation (friendly-automation) 2019-04-30 10:09:27.329-0500

Change 11318 merged by Friendly Automation:
app_amd: Fix infinite loop on silent calls

[https://gerrit.asterisk.org/c/asterisk/+/11318|https://gerrit.asterisk.org/c/asterisk/+/11318]

By: Jessie Kid Fernando (jessiekidf@gmail.com) 2019-10-24 15:33:42.999-0500

Hello Everyone,

Anyone knows why we are still getting stuck calls though we are already using this updated patch.

root@dialer-pq-apse1-lp27 apps]# asterisk -rx ‘module show like app_amd.so’
Module Description Use Count Status Support Level
app_amd.so Answering Machine Detection Application 1 Running extended
1 modules loaded


6ef6c801516 04:22:47 0000000010 0000000000 ( 0.00%) 0.0000 0000000001
0000000000 ( 0.00%) 0.0003


^C[root@dialer-pq-apse1-lp27 centos]# cat /var/log/asterisk/messages | grep C-00001f43
[Oct 24 11:24:25] VERBOSE[16627][C-00001f43] pbx.c: Executing [818508797407@default:1] AGI(“Local/818508797407@default-0000111a;2”, “agi://127.0.0.1:4577/call_log”) in new
[Oct 24 11:24:25] VERBOSE[16627][C-00001f43] res_agi.c: AGI Script Executing Application: (EXEC) Options: (Set(_CAMPCUST=OUTSOURC))
[Oct 24 11:24:25] VERBOSE[16627][C-00001f43] res_agi.c: <Local/818508797407@default-0000111a;2>AGI Script agi://127.0.0.1:4577/call_log completed, returning 0
[Oct 24 11:24:25] VERBOSE[16627][C-00001f43] pbx.c: Executing [818508797407@default:2] Set(“Local/818508797407@default-0000111a;2”, “CallerIDString=8508989521”) in new sta
[Oct 24 11:24:25] VERBOSE[16627][C-00001f43] pbx.c: Executing [818508797407@default:3] Set(“Local/818508797407@default-0000111a;2”, “CALLERID(num)=+18508989521”) in new st
[Oct 24 11:24:25] VERBOSE[16627][C-00001f43] pbx.c: Executing [818508797407@default:4] NoOp(“Local/818508797407@default-0000111a;2”, “CallerID : +18508989521”) in new stac
[Oct 24 11:24:25] VERBOSE[16627][C-00001f43] pbx.c: Executing [818508797407@default:5] Dial(“Local/818508797407@default-0000111a;2”, “SIP/magna1/18508797407,tTo”) in new
[Oct 24 11:24:25] VERBOSE[16627][C-00001f43] netsock2.c: Using SIP RTP CoS mark 5
[Oct 24 11:24:25] VERBOSE[16627][C-00001f43] app_dial.c: Called SIP/magna1/18508797407
[Oct 24 11:24:29] VERBOSE[5172][C-00001f43] res_rtp_asterisk.c: 0x7f167807b2c0 – Strict RTP learning after remote address set to: 173.245.44.26:44640
[Oct 24 11:24:29] VERBOSE[16627][C-00001f43] app_dial.c: SIP/magna1-00000ee8 is making progress passing it to Local/818508797407@default-0000111a;2
[Oct 24 11:24:29] VERBOSE[16627][C-00001f43] app_dial.c: SIP/magna1-00000ee8 redirecting info has changed, passing it to Local/818508797407@default-0000111a;2
[Oct 24 11:24:31] VERBOSE[16627][C-00001f43] app_dial.c: SIP/magna1-00000ee8 is ringing
[Oct 24 11:24:31] VERBOSE[16627][C-00001f43] app_dial.c: SIP/magna1-00000ee8 is making progress passing it to Local/818508797407@default-0000111a;2
[Oct 24 11:24:33] VERBOSE[16627][C-00001f43] app_dial.c: SIP/magna1-00000ee8 answered Local/818508797407@default-0000111a;2
[Oct 24 11:24:33] VERBOSE[16786][C-00001f43] bridge_channel.c: Channel SIP/magna1-00000ee8 joined ‘simple_bridge’ basic-bridge <211cac66-2869-42b4-a976-6e8230aca605>
[Oct 24 11:24:33] VERBOSE[16627][C-00001f43] bridge_channel.c: Channel Local/818508797407@default-0000111a;2 joined ‘simple_bridge’ basic-bridge <211cac66-2869-42b4-a976-6>
[Oct 24 11:24:33] VERBOSE[16786][C-00001f43] bridge_channel.c: Channel SIP/magna1-00000ee8 left ‘simple_bridge’ basic-bridge <211cac66-2869-42b4-a976-6e8230aca605>
[Oct 24 11:24:33] VERBOSE[16627][C-00001f43] bridge_channel.c: Channel Local/818508797407@default-0000111a;2 left ‘simple_bridge’ basic-bridge <211cac66-2869-42b4-a976-6e8
[Oct 24 11:24:33] VERBOSE[16627][C-00001f43] pbx.c: Spawn extension (default, 818508797407, 5) exited non-zero on ‘Local/818508797407@default-0000111a;2’
[Oct 24 11:24:33] VERBOSE[16786][C-00001f43] pbx.c: Executing [8387@default:1] Playback(“SIP/magna1-00000ee8”, “sip-silence”) in new stack
[Oct 24 11:24:33] VERBOSE[16627][C-00001f43] pbx.c: Executing [h@default:1] AGI(“Local/818508797407@default-0000111a;2”, “agi://127.0.0.1:4577/call_log–HVcauses–PRI------16-----ANSWER-----8-----0-----SIP 200 OK)”) in new stack
[Oct 24 11:24:33] VERBOSE[16786][C-00001f43] file.c: <SIP/magna1-00000ee8> Playing ‘sip-silence.gsm’ (language ‘en’)
[Oct 24 11:24:33] VERBOSE[16786][C-00001f43] res_rtp_asterisk.c: 0x7f167807b2c0 – Strict RTP switching to RTP target address 173.245.44.26:44640 as source
[Oct 24 11:24:33] VERBOSE[16786][C-00001f43] pbx.c: Executing [8387@default:2] AGI(“SIP/magna1-00000ee8”, “agi://127.0.0.1:4577/call_log”) in new stack
[Oct 24 11:24:33] VERBOSE[16786][C-00001f43] res_agi.c: AGI Script Executing Application: (EXEC) Options: (Set(_CAMPCUST=OUTSOURC))
[Oct 24 11:24:33] VERBOSE[16786][C-00001f43] res_agi.c: <SIP/magna1-00000ee8>AGI Script agi://127.0.0.1:4577/call_log completed, returning 0
[Oct 24 11:24:33] VERBOSE[16786][C-00001f43] pbx.c: Executing [8387@default:3] AMD(“SIP/magna1-00000ee8”, “2000,2000,1000,5000,120,50,4,256”) in new stack
[Oct 24 11:24:33] VERBOSE[16786][C-00001f43] app_amd.c: AMD: SIP/magna1-00000ee8 (N/A) (N/A) (Fmt: slin)
[Oct 24 11:24:33] VERBOSE[16786][C-00001f43] app_amd.c: AMD: initialSilence [2000] greeting [2000] afterGreetingSilence [1000] totalAnalysisTime [5000] minimumWordLength [nWordsSilence [50] maximumNumberOfWords [4] silenceThreshold [256] maximumWordLength [5000]
[Oct 24 11:24:33] VERBOSE[16786][C-00001f43] app_amd.c: AMD: Channel [SIP/magna1-00000ee8]. Detected Talk, previous silence duration: 40
[Oct 24 11:24:34] VERBOSE[16627][C-00001f43] res_agi.c: <Local/818508797407@default-0000111a;



This is the patch for the latest AMD module.


          /* Figure out how long we waited */
           if (res >= 0) {
                   ms = 2 * maxWaitTimeForFrame - res;
           }

           /* If we fail to read in a frame, that means they hung up */
           if (!(f = ast_read(chan))) {
                   ast_verb(3, "AMD: Channel [%s]. HANGUP\n", ast_channel_name(chan));
                   ast_debug(1, "Got hangup\n");
                   strcpy(amdStatus, "HANGUP");
                   res = 1;
                   break;
           }

           } else {
                   iTotalTime += ms;
                   if (iTotalTime >= totalAnalysisTime) {
                           ast_frfree(f);
                           strcpy(amdStatus , "NOTSURE");
                           sprintf(amdCause , "TOOLONG-%d", iTotalTime);
                           break;
                   }

By: Abhay Gupta (agupta) 2019-10-24 21:23:49.156-0500

From your code it does not seem that you applied the patch . There is a else block for res >=0 and also null frame is to be handled without which the AMD calls will get stuck

By: Asterisk Team (asteriskteam) 2019-10-24 21:23:49.599-0500

This issue has been reopened as a result of your commenting on it as the reporter. It will be triaged once again as applicable.

By: Jessie Kid Fernando (jessiekidf@gmail.com) 2019-10-25 07:26:25.323-0500

Hello,

Quick question, How can I apply the patch? Are you referring to this patch?

--- app_amd.c 2018-10-31 12:52:41.229343351 +0000
+++ app_amd.c 2018-10-31 12:52:07.297094203 +0000
@@ -282,6 +282,8 @@
/* Figure out how long we waited */
if (res > 0) {
ms = 2 * maxWaitTimeForFrame - res;
+ } else {
+ ms = 2 * maxWaitTimeForFrame;
}

/* If we fail to read in a frame, that means they hung up */
@@ -293,7 +295,7 @@
break;
}

- if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_CNG) {
+ if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_CNG || f->frametype == AST_FRAME_NULL) {
/* Figure out how long the frame is in milliseconds */
if (f->frametype == AST_FRAME_VOICE) {
framelength = (ast_codec_samples_count(f) / DEFAULT_SAMPLES_PER_MS);

Can I just insert these lines on app_amd.c? then just reload the module app_amd.so?

Regards,

Jessie

By: Jessie Kid Fernando (jessiekidf@gmail.com) 2019-10-25 07:51:07.806-0500

Is this the correct procedure for the patch to take effect?

1. Download the source
2. Run the patch script > I tried "patch /usr/src/asterisk-13.27.0/apps/app_amd.c < /tmp/amd.patch"
3. Compile Asterisk as normal  > What I did is 1. executed "make" 2. executed "make install"



By: Jessie Kid Fernando (jessiekidf@gmail.com) 2019-10-25 08:10:35.422-0500

I have compiled this one and currently this is the code from line 280 - 308. Let me know if this is correct.

       /* Now we go into a loop waiting for frames from the channel */
       while ((res = ast_waitfor(chan, 2 * maxWaitTimeForFrame)) > -1) {
               int ms = 0;

               /* Figure out how long we waited */
               if (res > 0) {
                       ms = 2 * maxWaitTimeForFrame - res;
               } else {
                       ms = 2 * maxWaitTimeForFrame;
               }

               /* If we fail to read in a frame, that means they hung up */
               if (!(f = ast_read(chan))) {
                       ast_verb(3, "AMD: Channel [%s]. HANGUP\n", ast_channel_name(chan));
                       ast_debug(1, "Got hangup\n");
                       strcpy(amdStatus, "HANGUP");
                       res = 1;
                       break;
               }

               if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_CNG || f->frametype == AST_FRAME_NULL) {
                       /* Figure out how long the frame is in milliseconds */
                       if (f->frametype == AST_FRAME_VOICE) {
                               framelength = (ast_codec_samples_count(f) / DEFAULT_SAMPLES_PER_MS);
                       } else {
                               framelength = ms;
                       }

                       iTotalTime += framelength;


By: Jessie Kid Fernando (jessiekidf@gmail.com) 2019-10-25 18:48:22.181-0500

I am still seeing stuck calls even though I compiled the app_amd.c and install it again on asterisk 13.27.0. Did I miss anything here? This is the patch that I applied on the c file.

/* Now we go into a loop waiting for frames from the channel */
while ((res = ast_waitfor(chan, 2 * maxWaitTimeForFrame)) > -1) {
int ms = 0;

/* Figure out how long we waited */
if (res >= 0)

{ ms = 2 * maxWaitTimeForFrame - res; }
else

{ ms = 2 * maxWaitTimeForFrame; }
/* If we fail to read in a frame, that means they hung up */
if (!(f = ast_read(chan)))

{ ast_verb(3, "AMD: Channel [%s]. HANGUP\n", ast_channel_name(chan)); ast_debug(1, "Got hangup\n"); strcpy(amdStatus, "HANGUP"); res = 1; break; }
if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_CNG || f->frametype == AST_FRAME_NULL) {
/* Figure out how long the frame is in milliseconds */
if (f->frametype == AST_FRAME_VOICE)

{ framelength = (ast_codec_samples_count(f) / DEFAULT_SAMPLES_PER_MS); }
else

{ framelength = ms; }
iTotalTime += framelength;

By: Jessie Kid Fernando (jessiekidf@gmail.com) 2019-10-28 15:27:21.113-0500

Hi Everyone,

Hope you could help. This one appears to be a stuck call. No rtp activity and was stuck on AMD application.

Stuck call on channelstats:

168.215.247.130  4d01b98619b  00:21:15 0000000131  0000000000 ( 0.00%) 0.0000 0000000001  0000000000 ( 0.00%) 0.0033

[root@dialer-pq-apse1-lp27 asterisk]# asterisk -rx 'sip show channel 4d01b98619b'

 * SIP Call
 Curr. trans. direction:  Outgoing
 Call-ID:                4d01b98619b5ae284b8f668805aeca22@18.141.37.93:5060
 Owner channel ID:       SIP/magna1-00005efa
 Our Codec Capability:   (ulaw)
 Non-Codec Capability (DTMF):   1
 Their Codec Capability:   (ulaw)
 Joint Codec Capability:   (ulaw)
 Format:                 (ulaw)
 T.38 support            No
 Video support           No
 MaxCallBR:              384 kbps
 Theoretical Address:    168.215.247.130:5060
 Received Address:       168.215.247.130:5060
 SIP Transfer mode:      open
 Force rport:            Yes
 Audio IP:               18.141.37.93 (local)
 Our Tag:                as78cd1ae6
 Their Tag:              DK3pmg6SN4tUe
 SIP User agent:
 Username:               19896592282
 Peername:               magna1
 Original uri:           sip:19896592282@168.215.247.130:5060
 Need Destroy:           No
 Last Message:           Tx: ACK
 Promiscuous Redir:      No
 Route:                  <sip:168.215.247.130:5060;lr>, <sip:sansay125352536rdb124155@67.221.11.72:5060;lr;transport=udp>
 DTMF Mode:              rfc2833
 SIP Options:            (none)
 Session-Timer:          Inactive
 Transport:              UDP
 Media:                  RTP


[root@dialer-pq-apse1-lp27 asterisk]# asterisk -rx 'core show channel   T.38 support            No'
Usage: core show channel <channel>
      Shows lots of information about the specified channel.
[root@dialer-pq-apse1-lp27 asterisk]#
[root@dialer-pq-apse1-lp27 asterisk]# asterisk -rx 'core show channel SIP/magna1-00005efa'
-- General --
          Name: SIP/magna1-00005efa
          Type: SIP
      UniqueID: 1572292970.151591
      LinkedID: 1572292970.151589
     Caller ID: +19892827928
Caller ID Name: V0281602480040267347
Connected Line ID: +19892827928
Connected Line ID Name: V0281602480040267347
Eff. Connected Line ID: +19892827928
Eff. Connected Line ID Name: V0281602480040267347
   DNID Digits: (N/A)
      Language: en
         State: Up (6)
 NativeFormats: (ulaw)
   WriteFormat: slin
    ReadFormat: slin
WriteTranscode: Yes (slin@8000)->(ulaw@8000)
 ReadTranscode: Yes (ulaw@8000)->(slin@8000)
Time to Hangup: 0
  Elapsed Time: 0h17m57s
     Bridge ID: (Not bridged)
--   PBX   --
       Context: default
     Extension: 8387
      Priority: 3
    Call Group: 0
  Pickup Group: 0
   Application: AMD
          Data: 2000,2000,1000,5000,120,50,4,256
Call Identifer: [C-0000c6eb]
     Variables:
AGISTATUS=SUCCESS
CAMPCUST=OUTSOURC
PLAYBACKSTATUS=SUCCESS
DIALEDPEERNUMBER=magna1/19896592282
SIPCALLID=4d01b98619b5ae284b8f668805aeca22@18.141.37.93:5060
 CDR Variables:
level 1: clid="V0281602480040267347" <+19892827928>
level 1: src=+19892827928
level 1: dst=8387
level 1: dcontext=default
level 1: channel=SIP/magna1-00005efa
level 1: lastapp=AppDial
level 1: lastdata=(Outgoing Line)
level 1: start=1572292970.109709
level 1: answer=1572292987.090434
level 1: end=1572292987.093691
level 1: duration=16
level 1: billsec=0
level 1: disposition=8
level 1: amaflags=3
level 1: uniqueid=1572292970.151591
level 1: linkedid=1572292970.151589
level 1: sequence=103234

level 2: clid="V0281602480040267347" <+19892827928>
level 2: src=+19892827928
level 2: dst=8387
level 2: dcontext=default
level 2: channel=SIP/magna1-00005efa
level 2: lastapp=AMD
level 2: lastdata=2000,2000,1000,5000,120,50,4,256
level 2: start=1572292987.361315
level 2: answer=1572292987.361316
level 2: end=0.000000
level 2: duration=1060
level 2: billsec=1060
level 2: disposition=1
level 2: amaflags=3
level 2: uniqueid=1572292970.151591
level 2: linkedid=1572292970.151589
level 2: sequence=103388


By: Richard Mudgett (rmudgett) 2019-10-28 16:23:56.119-0500

[~jessiekidf@gmail.com] The patch associated with this issue was committed to the code-base and released in the Target Release Versions indicated above.  The Target Release Versions already have the patch applied.  Explicitly applying the patch attached to this issue may not work.  All patches go through the code review process \[1] on Gerrit and likely get changes due to feedback.  The comments by "Friendly Automation" provide links to the review and the patches that were actually committed to the release branches.

\[1] https://wiki.asterisk.org/wiki/display/AST/Code+Review

By: Jessie Kid Fernando (jessiekidf@gmail.com) 2019-10-29 10:32:44.633-0500

Hi Richard, thank you so much for your inputs. Actually  I am using version 13.27.0 and then after that I applied the patch using the attached file on this JIRA ticket. I am not actually sure if I have missed the way I applied the patch. The process that I went through:

1. Downloaded the source asterisk-13.27.0.tar.gz from https://downloads.asterisk.org/pub/telephony/asterisk/old-releases/
2. Applied the patch on app_amd.c
3. Executed ./configure
4. Executed make menuselect (Just to ensure that the app_amd was selected)
5. Executed make
6. Execute make install
7. Reboot server




By: Richard Mudgett (rmudgett) 2019-10-29 11:40:39.268-0500

{quote}
1. Downloaded the source asterisk-13.27.0.tar.gz from https://downloads.asterisk.org/pub/telephony/asterisk/old-releases/
2. Applied the patch on app_amd.c
3. Executed ./configure
4. Executed make menuselect (Just to ensure that the app_amd was selected)
5. Executed make
6. Execute make install
7. Reboot server
{quote}
Why are you applying the patch to a version that already has the fix for this issue in it?  You are causing yourself grief.  Just delete step 2.

The patch attached to this issue ([^amd.patch]) is the original patch before it went through code review.  It is not the patch that ultimately went into the code-base.


By: Jessie Kid Fernando (jessiekidf@gmail.com) 2019-10-29 12:16:55.630-0500

Hello Richard,

I applied the patch because upon looking into the app_amd.c the lines that were added and excluded from the patch file was not there. See below. This is from the app_amd.c from asterisk-13.27.0.tar.gz under /app/

       /* Now we go into a loop waiting for frames from the channel */
       while ((res = ast_waitfor(chan, 2 * maxWaitTimeForFrame)) > -1) {
               int ms = 0;

               /* Figure out how long we waited */
               if (res >= 0) {
                       ms = 2 * maxWaitTimeForFrame - res;
               }

               /* If we fail to read in a frame, that means they hung up */
               if (!(f = ast_read(chan))) {
                       ast_verb(3, "AMD: Channel [%s]. HANGUP\n", ast_channel_name(chan));
                       ast_debug(1, "Got hangup\n");
                       strcpy(amdStatus, "HANGUP");
                       res = 1;
                       break;
               }

               if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_CNG) {
                       /* Figure out how long the frame is in milliseconds */
                       if (f->frametype == AST_FRAME_VOICE) {
                               framelength = (ast_codec_samples_count(f) / DEFAULT_SAMPLES_PER_MS);
                       } else {
                               framelength = ms;
                       }

                       iTotalTime += framelength;

                       ast_debug(1, "AMD: Channel [%s] frametype [%s] iTotalTime [%d] framelength [%d] totalAnalysisTime [%d]\n",
                                         ast_channel_name(chan),


By: Jessie Kid Fernando (jessiekidf@gmail.com) 2019-10-29 12:59:50.720-0500

Hi Richard,

I am little bit confused which one is the correct app_amd.c. Do you have the most updated app_amd.c that I can compile to the 13.27.0? Thanks in advance.

By: Richard Mudgett (rmudgett) 2019-10-29 13:42:01.884-0500

The fix for this issue is *already* in Asterisk 13.27.0.  You *do not* need to apply any patch.

By: Jessie Kid Fernando (jessiekidf@gmail.com) 2019-10-29 14:21:54.225-0500

I am actually using this app_amd.c. Let me know if this is all correct.

https://fullpotentialsolutions-my.sharepoint.com/:u:/g/personal/jessie_fernando_fullpotentialsolutions_onmicrosoft_com/EYr8rL_y6cFFvETpAtMHm_kB0OFhNN-iQt2DRaHrrunFIg?e=lTZmir

By: Jessie Kid Fernando (jessiekidf@gmail.com) 2019-10-29 14:23:35.468-0500

Hi Richard,

The reason why I applied the patch because right after installing the Asterisk 13.27.0 I was still seeing stuck channels that went through via AMD application. There was still stuck channels via AMD using the default source.

By: Richard Mudgett (rmudgett) 2019-10-29 14:45:16.568-0500

There was another AMD issue (ASTERISK-28419) that was fixed in v13.28.0.  That is the only change made to app_amd.c after v13.27.0.  If you are still having problems you need to file a new issue \[1].  Also be aware that AMD is extended support \[2].

\[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines
\[2] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Module+Support+States

By: Abhay Gupta (agupta) 2019-10-29 19:49:18.452-0500

Compile with latest version of asterisk with don’t optimise and better backtraces option . In case of any issue take gdb of running process with thread apply all bt and we should be able to help you with the solution .

By: Asterisk Team (asteriskteam) 2019-10-29 19:49:18.838-0500

This issue has been reopened as a result of your commenting on it as the reporter. It will be triaged once again as applicable.

By: Jessie Kid Fernando (jessiekidf@gmail.com) 2019-10-30 07:46:53.432-0500

Just for the record. This is the version I am using.  And this is the app_amd.c that I am using when compiling the entire system. Let me know if this is correct or not. The source file (asterisk-13.27.0.tar.gz) was from https://downloads.asterisk.org/pub/telephony/asterisk/old-releases/.



https://fullpotentialsolutions-my.sharepoint.com/:u:/g/personal/jessie_fernando_fullpotentialsolutions_onmicrosoft_com/EYr8rL_y6cFFvETpAtMHm_kB0OFhNN-iQt2DRaHrrunFIg?e=lTZmir

PBX Core settings
-----------------
 Version:                     13.27.0
 Build Options:               BUILD_NATIVE, OPTIONAL_API
 Maximum calls:               Not set
 Maximum open file handles:   65536
 Root console verbosity:      21
 Current console verbosity:   0
 Debug level:                 0
 Maximum load average:        0.000000
 Minimum free memory:         0 MB
 Startup time:                05:47:30
 Last reload time:            07:55:07
 System:                      Linux/3.10.0-957.1.3.el7.x86_64 built by root on x86_64 2019-10-21 12:54:52 UTC
 System name:
 Entity ID:                   02:99:d4:63:f7:48
 PBX UUID:                    9998f983-1225-4545-a487-ba193b845f9b
 Default language:            en
 Language prefix:             Enabled
 User name and group:         /
 Executable includes:         Disabled
 Transcode via SLIN:          Enabled
 Transmit silence during rec: Disabled
 Generic PLC:                 Enabled
 Generic PLC on equal codecs: Disabled
 Min DTMF duration::          80
 Cache media frames:          Enabled
 RTP dynamic payload types:   96-127

* Subsystems
 -------------
 Manager (AMI):               Enabled
 Web Manager (AMI/HTTP):      Disabled
 Call data records:           Enabled
 Realtime Architecture (ARA): Disabled

* Directories
 -------------
 Configuration file:          /etc/asterisk/asterisk.conf
 Configuration directory:     /etc/asterisk
 Module directory:            /usr/lib/asterisk/modules
 Spool directory:             /var/spool/asterisk
 Log directory:               /var/log/asterisk
 Run/Sockets directory:       /var/run/asterisk
 PID file:                    /var/run/asterisk/asterisk.pid
 VarLib directory:            /var/lib/asterisk
 Data directory:              /var/lib/asterisk
 ASTDB:                       /var/lib/asterisk/astdb
 IAX2 Keys directory:         /var/lib/asterisk/keys
 AGI Scripts directory:       /var/lib/asterisk/agi-bin


By: Jessie Kid Fernando (jessiekidf@gmail.com) 2019-11-05 11:51:55.768-0600

Hello Jcolp,

Thanks for providing the linked issue about this topic. I'll just wait once we have the fixed patch on it. Thanks.

Regards,

Jessie