[Freeswitch-users] mod_managed - beginner's question about an event listener module
Dave R. Kompel
drk at drkngs.net
Sat Sep 21 19:23:03 MSD 2013
I just looked at your code, and it's really simple to fix :)
In your tProc routine, add another ec.bind("SHUTDOWN",String.Empty) so that you get the shutdown events. Then in your while loop, if the event is "SHUTDOWN", then set the _stop = true. Also you can get rid of the "_bind" list cause you're not using it...
You also can get rid of implmenting IDisposable yourself, since mod_managed does not Dispose() for you. As long as you exit your thread loop when you get the "SHUTDOWN" event, you should be fine.
Also since you are implmenting an API interface, you may want to do something like:
if(context.args.ToLower() == "shutdown")
_stop = true;
So you can force it to shutdown, and then you can replace the DLL to load a new version while FS is still running.
--Dave
_____
From: Rafal Gwizdala [mailto:rafal.gwizdala at gmail.com]
To: FreeSWITCH Users Help [mailto:freeswitch-users at lists.freeswitch.org]
Sent: Sat, 21 Sep 2013 00:11:41 -0700
Subject: Re: [Freeswitch-users] mod_managed - beginner's question about an event listener module
Dave, there must be something else. I did as you suggested, but my module will hang during shutdown.
The program hangs on EventConsumer.Dispose.
http://pastebin.com/58NRKSPf
FreeSWITCH Version 1.5.6b+git~20130912T164754Z~d9216daedb (git d9216da 2013-09-12 16:47:54Z)
windows 7 64 bit
but
if the EventConsumer is disposed before system shutdown (for example, after consuming a certain number of events), there is no problem, event receiver thread terminates correctly and system shuts down cleanly.
I think i can live with that. Thanks for your help.
R
On Sat, Sep 21, 2013 at 3:56 AM, Dave R. Kompel <drk at drkngs.net> wrote:
To answer all your questions at once...
put the EventConsumer inside a using() block, so it gets disposed.
use a static boolean variable in a while loop to .pop the event consumer with a timeout, if pop returns null "continue" the while loop.
Subscribe to shutdown, it sets the loop variable to false.
API command "shutdown" in the same module to set the variable to false also, so you can unload your module at will w/o crashing
This whole loop shoud be run on it's own thread started from the Load() method.
--Dave
_____
From: Rafal Gwizdala [mailto:rafal.gwizdala at gmail.com]
To: FreeSWITCH Users Help [mailto:freeswitch-users at lists.freeswitch.org]
Sent: Fri, 20 Sep 2013 04:08:58 -0700
Subject: Re: [Freeswitch-users] mod_managed - beginner's question about an event listener module
(...)
my source code: http://pastebin.com/bKPyKSwS
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting at freeswitch.org
http://www.freeswitchsolutions.com
Official FreeSWITCH Sites
http://www.freeswitch.org
http://wiki.freeswitch.org
http://www.cluecon.com
FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20130921/d808e7bf/attachment-0001.html
Join us at ClueCon 2013 Aug 6-8, 2013
More information about the FreeSWITCH-users
mailing list