Since chan_sip is callback devicestate driven do not pass in actual states, pass...
authorJoshua Colp <jcolp@digium.com>
Fri, 12 Dec 2008 16:55:15 +0000 (16:55 +0000)
committerJoshua Colp <jcolp@digium.com>
Fri, 12 Dec 2008 16:55:15 +0000 (16:55 +0000)
(closes issue #13525)
Reported by: pj

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@163579 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c
main/channel.c

index 251e05a..51fc59b 100644 (file)
@@ -10863,7 +10863,7 @@ static int expire_register(const void *data)
        
        manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: SIP\r\nPeer: SIP/%s\r\nPeerStatus: Unregistered\r\nCause: Expired\r\n", peer->name);
        register_peer_exten(peer, FALSE);       /* Remove regexten */
-       ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "SIP/%s", peer->name);
+       ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
 
        /* Do we need to release this peer from memory? 
                Only for realtime peers and autocreated peers
@@ -11552,7 +11552,7 @@ static void sip_peer_hold(struct sip_pvt *p, int hold)
        ast_atomic_fetchadd_int(&peer->onHold, (hold ? +1 : -1));
 
        /* Request device state update */
-       ast_devstate_changed(hold ? AST_DEVICE_ONHOLD : AST_DEVICE_INUSE, "SIP/%s", peer->name);
+       ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
        unref_peer(peer, "sip_peer_hold: from find_peer operation");
        
        return;
@@ -16730,7 +16730,7 @@ static void handle_response_peerpoke(struct sip_pvt *p, int resp, struct sip_req
 
                ast_log(LOG_NOTICE, "Peer '%s' is now %s. (%dms / %dms)\n",
                        peer->name, s, pingtime, peer->maxms);
-               ast_devstate_changed(is_reachable ? AST_DEVICE_NOT_INUSE : AST_DEVICE_UNAVAILABLE, "SIP/%s", peer->name);
+               ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
                manager_event(EVENT_FLAG_SYSTEM, "PeerStatus",
                        "ChannelType: SIP\r\nPeer: SIP/%s\r\nPeerStatus: %s\r\nTime: %d\r\n",
                        peer->name, s, pingtime);
@@ -21055,7 +21055,7 @@ static int sip_poke_noanswer(const void *data)
        }
        
        peer->lastms = -1;
-       ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "SIP/%s", peer->name);
+       ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
 
        /* Try again quickly */
        AST_SCHED_REPLACE_UNREF(peer->pokeexpire, sched, 
index 3debac5..b11caf8 100644 (file)
@@ -4170,7 +4170,12 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
        }
 
        chan->_state = state;
-       ast_devstate_changed_literal(ast_state_chan2dev(state), name);
+
+       /* We have to pass AST_DEVICE_UNKNOWN here because it is entirely possible that the channel driver
+        * for this channel is using the callback method for device state. If we pass in an actual state here
+        * we override what they are saying the state is and things go amuck. */
+       ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, name);
+
        /* setstate used to conditionally report Newchannel; this is no more */
        manager_event(EVENT_FLAG_CALL,
                      "Newstate",