Summary:ASTERISK-02848: Use counter not decremented after timeout in INVITE
Reporter:psaar (psaar)Labels:
Date Opened:2004-11-18 06:48:56.000-0600Date Closed:2004-11-25 02:20:47.000-0600
Versions:Frequency of
Environment:Attachments:( 0) inuse-trace.txt
( 1) stopgap-patch.diff
Description:Dialing out on SIP channel increments the inUse variable in  user data. Under normal conditions it gets decremented when call terminates either because the phone is unreachable, ring timeout is reached or the call is hung up.

If dialing when the phone is already unreachable but SIP channel has not determined it yet, the channel driver gets a retransmission error (chan_sip.c:681), both halves of the call get torn down but usage count is left dangling.

The time window for this happening is small, no more than interval between sip_poke_peer's.
Comments:By: psaar (psaar) 2004-11-20 10:37:06.000-0600

update_user_counter(p, DEC_OUT_USE) gets called in sip_hangup but then the channel tries to send a CANCEL request to the phone and usage count is incremeted again at sip_channel.c:1811, also channel destruction is scheduled at row 1806.

After 15 seconds the scheduler prints out "Attempted to delete non-existant schedule entry <blaah>" - it seems to me that the channel gets destroyed but usage count is left alone.

I do not know all the code paths good enough; one stopgap measure would be to set alreadygone=1 in retrans_pkt when retry count is exceeded, disabling sending  additional packets in sip_hangup (chan_sip.c:1795) - the rationale being that there is no one to receive them.

By: Mark Spencer (markster) 2004-11-20 10:58:14.000-0600

Your fix is actually very correct I think.  Added to CVS head.

By: Russell Bryant (russell) 2004-11-25 02:20:47.000-0600

fixed in 1.0 - will be in 1.0.3