[asterisk-dev] incorrect generation of Newchannel manager event

Moises Silva moises.silva at gmail.com
Wed Aug 30 18:46:35 MST 2006


Hi. In our development we are doing extensive use of manager events,
including all the events related to channel creation and change of
state (Newchannel, Newstate). I have noticed that Newchannel is
incorrectly generated sometimes because in channel.c ->
ast_setstate(), exists a condition like this:

(oldstate == AST_STATE_DOWN) ? "Newchannel" : "Newstate",

So, when changing state from Down to something else, a Newchannel
event is launched. This causes that sometimes 2 Newchannel events are
generated. For example, when calling ast_request() followed by some
call to ast_setstate(), because ast_request generates a Newchannel
event, and ast_setstate also generates the same event for the same
channel, but with different state, when it should be launched a
Newstate event.

I think the problem is that is not well defined when a Newchannel
event should be generated?

We can workaround this by simply putting our event callback to check
the Newchannel event for state change too, but as I said, I think this
is incorrect. I dont know very well the Asterisk architecture, but I
see 3 main options:

1. Remove the condition in ast_setstate(), and this could possibly
break things in other situations.
2. Add a new member to ast_channel structure to define when the
channel is not new yet. So ast_setstate could check this instead of
the "_state" member.
3. Add or use some new state to set in ast_request() instead of
returning the channel in AST_STATE_DOWN, wich possibly would break
things?

Feedback will be appreciated before filling a bug in mantis.

Regards



-- 
"Su nombre es GNU/Linux, no solamente Linux, mas info en http://www.gnu.org"



More information about the asterisk-dev mailing list