[asterisk-bugs] [Asterisk 0013668]: sip show inuse count is negative

Asterisk Bug Tracker noreply at bugs.digium.com
Fri Oct 10 15:44:50 CDT 2008


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=13668 
====================================================================== 
Reported By:                mjc
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   13668
Category:                   Channels/chan_sip/General
Reproducibility:            random
Severity:                   minor
Priority:                   normal
Status:                     new
Asterisk Version:           1.6.0 
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             2008-10-10 15:02 CDT
Last Modified:              2008-10-10 15:44 CDT
====================================================================== 
Summary:                    sip show inuse count is negative
Description: 
I have a bunch of snom 360s and asterisk-1.6.0-rc6. The snom BLF LEDs
monitor hints. However, the hints are getting confused and inverting state
sometimes. That is, unused extensions are being shown as in-use, and
vice-versa.

If I run "sip show inuse" during these times, I see entries like this:

steerpike*CLI> sip show inuse
* User name               In use          Limit
mjc_server                0               10
mjc_library               0               10
mjc_lab                   0               10
mjc_office                0               10
mjc_home                  0               10
* Peer name               In use          Limit
mjc_server                0/0/0           10
mjc_library               0/0/0           10
mjc_lab                   -1/0/0          10
mjc_office                0/0/0           10
mjc_home                  0/0/0           10

Note the "-1"! This is nonsense, and results in an "in use" hint:

steerpike*CLI> core show hints
                    601 at internal            : SIP/mjc_office&SIP/m 
State:InUse           Watchers 11

where the defined hint is:

exten =>
601,hint,SIP/mjc_office&SIP/mjc_home&SIP/mjc_lab&SIP/mjc_server&SIP/mjc_library


Somehow, the call count is being decremented by 2 after a hangup (from 1
to -1). Call counts should be clamped at zero, I would suggest.

This problem did not occur on the same system when we had 1.2.x and 1.4.x
running.

- Mike
====================================================================== 

---------------------------------------------------------------------- 
 (0093504) putnopvut (administrator) - 2008-10-10 15:44
 http://bugs.digium.com/view.php?id=13668#c93504 
---------------------------------------------------------------------- 
There  are checks in the code to make sure that the inuse count on a sip
user/peer does not drop below 0. However, it looks like even though we use
atomic operations to change the values, there is no lock around the code,
which still allows for race conditions. I think it may be possible to
resolve this by making sure to hold a lock around the critical section.

Since there is just one function in all of the SIP code which adjusts this
value, it seems to me as though adding a lock is exactly what is needed to
get this to work correctly.

I normally like to upload patches and get users to test and report back,
but considering how randomly this issue probably occurs and the fact that
it may take anywhere from a few days to a few weeks with the patch applied
to see if the problem recurs, I'm going to apply the locking idea I
described and commit the fix to trunk/1.6.0/1.6.1 and close this issue. If
you encounter the issue again after using an updated version, then please
do not hesitate to re-open this bug. Thanks for the report. 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2008-10-10 15:44 putnopvut      Note Added: 0093504                          
======================================================================




More information about the asterisk-bugs mailing list