[asterisk-dev] Re: Question about ast_async_goto()

Tony Mountifield tony at softins.clara.co.uk
Tue Aug 22 08:30:55 MST 2006


In article <28109133.29651156254603803.JavaMail.root at jupiler.digium.com>,
Kevin P. Fleming <kpfleming at digium.com> wrote:
> ----- Tony Mountifield <tony at softins.clara.co.uk> wrote:
> > What part of the code should be responsible for issuing ast_hangup()
> > on the
> > original channel B (seq .3)?
> 
> This should be handled by ast_do_masquerade(). However, if nothing is reading from that
> channel, then the pending hangup will never get processed. It's not clear exactly why this
> isn't working in your application, though.

Thanks. Nothing was reading from that channel, which is probably why it
stayed around. However, what I discovered is that I could call ast_hangup()
immediately after the ast_async_goto(), like this:

ast_async_goto(chanb, context, exten, pri);
ast_hangup(chanb);

(error checking omitted for clarity). Then the zombie channel was tidied up.

The only niggling doubt I had was whether there was any race condition that
would make this unsafe, i.e. hanging up the original channel before the
async goto had finished getting everything it needed from it. So long as
everything was done in the thread calling ast_async_goto(), before it returns,
then I guess it should be fine.

Just for interest sake, what I'm actually working on is dialling out from
Meetme to invite new participants. I started with the patch on bug 3405,
but it doesn't create a proper call sequence, nor generate sensible
Manager API events. It just creates its own local thread in which to run
conf_run() for the invited participant. Instead, I've decided to do it by
using ast_async_goto() to send the invited participant into the dialplan
on its own pbx thread (after consultation with the call initiator), so
that they can be tracked by my AGI accounting and go into Meetme properly
via the front door. They will then also execute the h extension on the way
out, which I also need.

Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-dev mailing list