[Home]

Summary:ASTERISK-15052: [patch] MixMonitor thread doesn't exit until channel is dropped
Reporter:Alex Mota (alexms)Labels:
Date Opened:2009-10-29 06:07:01Date Closed:2009-11-19 15:40:18.000-0600
Priority:MajorRegression?Yes
Status:Closed/CompleteComponents:Applications/app_mixmonitor
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) stopmixmonitor_1.4.diff
Description:Hi,
I've noticed that when I apply MixMonitor/StopMixMonitor on a channel the thread (mixmonitor_thread) only exits when the channel is dropped. If you have several long calls being monitored, asterisk eats up a lot of memory - in my case all of it.

For example, using the following dialplan

exten => 103,1,Answer
exten => 103,n,MixMonitor(myfile)
exten => 103,n,Playback(beep)
exten => 103,n,StopMixMonitor
exten => 103,n,Wait(3)
exten => 103,n,Hangup

and observing the CLI (below) you can see that the message "End MixMonitor Recording" is always displayed (line 11) after the hang up and not after the StopMixMonitor (line 6), as it used to be. I say used to be, because I checked in versions 1.4.17 and 1.4.21.1 and it works fine.

The problem occurs for sure in version 1.4.26 and trunk (revision 226303).

TRUNK CLI:
(1)    -- Executing [103@from-internal:1] Answer("SIP/4000-08a713d0", "") in new stack
(2)    -- Executing [103@from-internal:2] MixMonitor("SIP/4000-08a713d0", "myfile") in new stack
(3)    -- Executing [103@from-internal:3] Playback("SIP/4000-08a713d0", "beep") in new stack
(4)  == Begin MixMonitor Recording SIP/4000-08a713d0
(5)    -- <SIP/4000-08a713d0> Playing 'beep' (language 'en')
(6)    -- Executing [103@from-internal:4] StopMixMonitor("SIP/4000-08a713d0", "") in new stack
(7)  == MixMonitor close filestream
(8)    -- Executing [103@from-internal:5] Wait("SIP/4000-08a713d0", "3") in new stack
(9)    -- Executing [103@from-internal:6] Hangup("SIP/4000-08a713d0", "") in new stack
(10)  == Spawn extension (from-internal, 103, 6) exited non-zero on 'SIP/4000-08a713d0'
(11)  == End MixMonitor Recording SIP/4000-08a713d0
(12)Really destroying SIP dialog 'MzY2NzI1YzAxZTBhZmFlY2E0NTZhMGMwNDkzMjQ0M2U.' Method: ACK

1.4.17 & 1.4.21.2 CLI:
(1)    -- Executing [103@from-internal:1] Answer("SIP/4000-081f01a0", "") in new stack
(2)    -- Executing [103@from-internal:2] MixMonitor("SIP/4000-081f01a0", "myfile") in new stack
(3)  == Begin MixMonitor Recording SIP/4000-081f01a0
(4)    -- Executing [103@from-internal:3] Playback("SIP/4000-081f01a0", "beep") in new stack
(5)    -- <SIP/4000-081f01a0> Playing 'beep' (language 'en')
(6)    -- Executing [103@from-internal:4] StopMixMonitor("SIP/4000-081f01a0", "") in new stack
(7)  == End MixMonitor Recording SIP/4000-081f01a0
(8)    -- Executing [103@from-internal:5] Wait("SIP/4000-081f01a0", "3") in new stack
(9)    -- Executing [103@from-internal:6] Hangup("SIP/4000-081f01a0", "") in new stack
(10)  == Spawn extension (from-internal, 103, 6) exited non-zero on 'SIP/4000-081f01a0'

Comments:By: David Vossel (dvossel) 2009-11-12 16:52:11.000-0600

I uploaded a patch that should resolve this issue.  Please test it and let me know.

The filestream is closed during StopMixMonitor allowing for the file to be accessible to the dialplan immediately, but the thread may close a hair later than when StopMixMonitor returns.  This means that you might see the "End Mixmonitor Recording" debug message appear after the next item executes in the dialplan.  Regardless, the thread now exits properly instead of waiting for channel destruction, the delay is just the time it takes for the mixmonitor thread to shutdown after the destruction condition is received.

By: David Vossel (dvossel) 2009-11-12 16:52:35.000-0600

A patch for this is on reviewboard, https://reviewboard.asterisk.org/r/424/

By: Alex Mota (alexms) 2009-11-16 09:09:34.000-0600

I've applied the patch and it works for me.
Thanks.

By: Digium Subversion (svnbot) 2009-11-19 15:29:23.000-0600

Repository: asterisk
Revision: 230508

U   branches/1.4/apps/app_mixmonitor.c

------------------------------------------------------------------------
r230508 | dvossel | 2009-11-19 15:29:22 -0600 (Thu, 19 Nov 2009) | 10 lines

fixes MixMonitor thread not exiting when StopMixMonitor is used

(closes issue ASTERISK-15052)
Reported by: AlexMS
Patches:
     stopmixmonitor_1.4.diff uploaded by dvossel (license 671)
Tested by: dvossel, AlexMS

Review: https://reviewboard.asterisk.org/r/424/

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=230508

By: Digium Subversion (svnbot) 2009-11-19 15:32:58.000-0600

Repository: asterisk
Revision: 230509

_U  trunk/
U   trunk/apps/app_mixmonitor.c

------------------------------------------------------------------------
r230509 | dvossel | 2009-11-19 15:32:58 -0600 (Thu, 19 Nov 2009) | 17 lines

Merged revisions 230508 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
 r230508 | dvossel | 2009-11-19 15:22:46 -0600 (Thu, 19 Nov 2009) | 10 lines
 
 fixes MixMonitor thread not exiting when StopMixMonitor is used
 
 (closes issue ASTERISK-15052)
 Reported by: AlexMS
 Patches:
       stopmixmonitor_1.4.diff uploaded by dvossel (license 671)
 Tested by: dvossel, AlexMS
 
 Review: https://reviewboard.asterisk.org/r/424/
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=230509

By: Digium Subversion (svnbot) 2009-11-19 15:35:31.000-0600

Repository: asterisk
Revision: 230510

_U  branches/1.6.2/
U   branches/1.6.2/apps/app_mixmonitor.c

------------------------------------------------------------------------
r230510 | dvossel | 2009-11-19 15:35:30 -0600 (Thu, 19 Nov 2009) | 24 lines

Merged revisions 230509 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
 r230509 | dvossel | 2009-11-19 15:26:21 -0600 (Thu, 19 Nov 2009) | 17 lines
 
 Merged revisions 230508 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r230508 | dvossel | 2009-11-19 15:22:46 -0600 (Thu, 19 Nov 2009) | 10 lines
   
   fixes MixMonitor thread not exiting when StopMixMonitor is used
   
   (closes issue ASTERISK-15052)
   Reported by: AlexMS
   Patches:
         stopmixmonitor_1.4.diff uploaded by dvossel (license 671)
   Tested by: dvossel, AlexMS
   
   Review: https://reviewboard.asterisk.org/r/424/
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=230510

By: Digium Subversion (svnbot) 2009-11-19 15:38:34.000-0600

Repository: asterisk
Revision: 230511

_U  branches/1.6.1/
U   branches/1.6.1/apps/app_mixmonitor.c

------------------------------------------------------------------------
r230511 | dvossel | 2009-11-19 15:38:33 -0600 (Thu, 19 Nov 2009) | 24 lines

Merged revisions 230509 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
 r230509 | dvossel | 2009-11-19 15:26:21 -0600 (Thu, 19 Nov 2009) | 17 lines
 
 Merged revisions 230508 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r230508 | dvossel | 2009-11-19 15:22:46 -0600 (Thu, 19 Nov 2009) | 10 lines
   
   fixes MixMonitor thread not exiting when StopMixMonitor is used
   
   (closes issue ASTERISK-15052)
   Reported by: AlexMS
   Patches:
         stopmixmonitor_1.4.diff uploaded by dvossel (license 671)
   Tested by: dvossel, AlexMS
   
   Review: https://reviewboard.asterisk.org/r/424/
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=230511

By: Digium Subversion (svnbot) 2009-11-19 15:40:14.000-0600

Repository: asterisk
Revision: 230512

_U  branches/1.6.0/
U   branches/1.6.0/apps/app_mixmonitor.c

------------------------------------------------------------------------
r230512 | dvossel | 2009-11-19 15:40:14 -0600 (Thu, 19 Nov 2009) | 24 lines

Merged revisions 230509 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
 r230509 | dvossel | 2009-11-19 15:26:21 -0600 (Thu, 19 Nov 2009) | 17 lines
 
 Merged revisions 230508 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r230508 | dvossel | 2009-11-19 15:22:46 -0600 (Thu, 19 Nov 2009) | 10 lines
   
   fixes MixMonitor thread not exiting when StopMixMonitor is used
   
   (closes issue ASTERISK-15052)
   Reported by: AlexMS
   Patches:
         stopmixmonitor_1.4.diff uploaded by dvossel (license 671)
   Tested by: dvossel, AlexMS
   
   Review: https://reviewboard.asterisk.org/r/424/
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=230512