Summary:ASTERISK-19531: Realtime SIP peers that explicitly unregister have incorrect device state.
Reporter:Andrew Ofisher (zaltar)Labels:
Date Opened:2012-03-13 12:05:30Date Closed:
Versions: 13.18.4 Frequency of
Environment:Asterisk, Cent OS 6.2 x64Attachments:( 0) asterisk-log-output-19531.txt
Description:I have realtime setup using OpenLDAP for sipusers. The user I was testing with is setup with host=dynamic, nat=yes, qualify=yes. In my sip.config I have rtcachefriends=yes, rtsavesysname=yes, rtupdate=yes, rtautoclear=yes, ignoreregexpire=no. This user is also in a queue. When the softphone registers and then explicitly unregisters, the queue will still show the user as "Not in use". Enabling debug output confirms that the device state is remaining "Not in use" instead of Unavailable. This does not happen if the softphone's registration expires.

It looks like ASTERISK-14953 is what broke this. Previously, the peer's fullcontact field was wiped out on unregister which subsequently caused the field to be wiped out in realtime. What happens now is that destroy_association, called from expire_register, will properly clear out the field in realtime but not the peer object. When parse_register_contact returns, register_verify will call update_peer (chan_sip.c:14836) which will cause fullcontact and other fields to be written back into realtime. When the queue checks the device state of the user and the user is loaded from realtime, sip_devicestate will return AST_DEVICE_NOT_INUSE instead of AST_DEVICE_UNAVAILABLE because p->addr won't be null.

I'll attach a full debug output showing the phone registering and unregistering and the devicestate still being Not in use.