Summary:ASTERISK-09508: [patch] Call counter not updating for looping request
Reporter:Remi Quezada (remiq)Labels:
Date Opened:2007-05-24 10:38:04Date Closed:2011-06-07 14:08:01
Versions:Frequency of
Environment:Attachments:( 0) bug_fixed.debug
( 1) bug.debug
( 2) bug.sipdebug
( 3) bug2.sip.debug
( 4) chan_sip.c.patch
Description:After I upgraded from version 1.2.14 to 1.2.18, I noticed that the peer and user call counters are not updating properly.  When you have an outbound call (peer) and Asterisk receives an incoming INVITE request, Asterisk will change the call to incoming (user).  Once the call gets changed to incoming, all future call counter updates will apply to the user counters.  When the call hangs up the user counter gets decremented, but the peer counter is not decremented and so is increased by 1 for each type of call like this.  If you have call-limits set in your sip.conf calls quickly begin failing to:

update_call_counter: Call to peer '7323825777' rejected due to usage limit of 1

I was able to fix this by updating the call counter before and after Asterisk changes the call to incoming.    

1) Receive INVITE on "standing outbound" call
2) update_call_counter: Decrement PEER counter
3) Change the call to incoming (USER)
4) update_call_counter: Increment the USER counter


I attached the patch.  I also included two debug files, one before the patch and one after the patch was applied.  

Oddly, we only receive this call pattern for FAX calls to an Adtran Total Access 900. For some reason when the Adtran receives a fax call it is sending the INVITE to the Asterisk.  
Comments:By: Curt Moore (jcmoore) 2007-05-25 12:52:16

Thanks for your submission. If you haven't already, please submit a disclaimer/license agreement which can be found at:


After you have submitted it, please add a note to the bug and then we can proceed by evaluating your patch.


By: Remi Quezada (remiq) 2007-05-25 16:16:32

I just finished faxing over the disclaimer/license agreement.


By: Olle Johansson (oej) 2007-05-29 01:49:50

What is your setting on "pedantic" in sip.conf?

By: Olle Johansson (oej) 2007-05-29 01:50:46

Please turn on SIP DEBUG for these logs. Thanks.

By: Remi Quezada (remiq) 2007-05-29 07:50:50

I do not have "pedantic" defined in my sip.conf.  I will post the SIP DEBUG logs later today.

By: Olle Johansson (oej) 2007-05-29 10:20:18

Turn on pedantic=yes in sip.conf general section and try again. Thanks.

By: Remi Quezada (remiq) 2007-05-30 14:55:36

I turned on pedantic in my sip.conf file and I am still able to reproduce this bug.  I uploaded a debug file with pedantic enabled and SIP DEBUG turned on.

By: Olle Johansson (oej) 2007-05-31 05:05:46

Ok, I need to check your logs, since according to all logic in asterisk these calls should fail. The question here is not really the inuse, but why Asterisk doesn't recognize the incoming call being the same as one outbound and fail.

By: Remi Quezada (remiq) 2007-06-15 11:20:37

I attached another file (bug2.sip.debug), this time it is happening when there is a reinvite.  The difference this time is that it is decrementing the peer instead of the user.

By: Lazaro Baca (lazaro) 2007-08-06 14:43:49

Confirmed in asterisk version 1.2.23 the same effect.

By: Jason Parker (jparker) 2007-08-29 17:21:00

Is this an issue in 1.4?

By: Joshua C. Colp (jcolp) 2007-09-11 14:13:50

I'm suspending this since there has been no reply to it being applicable to 1.4. If it is feel free to reopen with fresh info.