[asterisk-dev] [svn-commits] file: trunk r104539 - /trunk/channels/chan_sip.c

Russell Bryant russell at digium.com
Wed Feb 27 10:58:54 CST 2008


SVN commits to the Digium repositories wrote:
> Author: file
> Date: Wed Feb 27 10:26:57 2008
> New Revision: 104539
> 
> URL: http://svn.digium.com/view/asterisk?view=rev&rev=104539
> Log:
> When queueing up a device state change when the peer is loaded from the configuration give it a state of not in use. We have to do this because the channel technology may not yet be registered so the state could not be queried and would be considered invalid.
> (closes issue #12087)
> Reported by: liorm
> 
> Modified:
>     trunk/channels/chan_sip.c
> 
> Modified: trunk/channels/chan_sip.c
> URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=104539&r1=104538&r2=104539
> ==============================================================================
> --- trunk/channels/chan_sip.c (original)
> +++ trunk/channels/chan_sip.c Wed Feb 27 10:26:57 2008
> @@ -20527,7 +20527,7 @@
>  					}
>  					peer = build_peer(cat, gen, ast_variable_browse(ucfg, cat), 0);
>  					if (peer) {
> -						ast_device_state_changed("SIP/%s", peer->name);
> +						ast_devstate_changed(AST_DEVICE_NOT_INUSE, "SIP/%s", peer->name);
>  						ASTOBJ_CONTAINER_LINK(&peerl, peer);
>  						unref_peer(peer);
>  						peer_count++;
> @@ -20596,6 +20596,7 @@
>  			if (is_peer) {
>  				peer = build_peer(cat, ast_variable_browse(cfg, cat), NULL, 0);
>  				if (peer) {
> +					ast_devstate_changed(AST_DEVICE_NOT_INUSE, "SIP/%s", peer->name);
>  					ASTOBJ_CONTAINER_LINK(&peerl, peer);
>  					unref_peer(peer);
>  					peer_count++;

This change actually won't work, and it's very subtle why.  For that, I apologize.

The reason is, as soon as you switch to using ast_devstate_changed() with
providing explicit state values, the devicestate handling code then assumes that
you will _always_ be providing explicit state changes.  So, it will cache the
value that you have provided.  However, since no other state changes for SIP
peers use this method, this NOT_INUSE state is the only one that will ever get
cached.

So, what will happen is that any time some code (such as app_queue, for example)
polls for device state, the device state code will see that it has a value
cached, and will return it.  So, the peer will appear to be always NOT_INUSE.

To summarize, you can't use ast_devstate_changed() unless you change _all_
device state reporting for chan_sip to use it.  Furthermore, you can't change
all of SIP device state reporting without changing the higher level
ast_setstate() ast_channel function to use ast_devstate_changed().  And if you
do that, you have to change device state reporting for _all_ channel drivers ...

-- 
Russell Bryant
Senior Software Engineer
Open Source Team Lead
Digium, Inc.




More information about the asterisk-dev mailing list