[Home]

Summary:ASTERISK-14502: [patch] chan_sip behaves like crazy if there is not route to destination
Reporter:Nikos Mavrogianopoulos (nmav)Labels:
Date Opened:2009-07-21 03:55:54Date Closed:2009-09-10 15:07:36
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/Registration
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) chan_sip.patch
Description:If the host asterisk is running has no routes to the registration server I get continuous messages like below. In addition after ten minutes the machine crashes due to no memory available (asterisk takes it all).

[Apr  1 04:10:39] WARNING[916]: chan_sip.c:1804 __sip_xmit: sip_xmit of 0x15cb44
(len 403) to 192.168.240.34:5060 returned -2: Unknown error 101
[Apr  1 04:10:39] NOTICE[916]: chan_sip.c:8144 sip_reg_timeout:    -- Registrati
on for 'nmav2@192.168.240.34' timed out, trying again (Attempt ASTERISK-616)
[Apr  1 04:10:39] WARNING[916]: acl.c:548 ast_ouraddrfor: Cannot connect
REGISTER attempt 623 to nmav2@192.168.240.34
[Apr  1 04:10:39] WARNING[916]: chan_sip.c:1804 __sip_xmit: sip_xmit of 0x8f9f4c
(len 403) to 192.168.240.34:5060 returned -2: Unknown error 101
[Apr  1 04:10:39] NOTICE[916]: chan_sip.c:8144 sip_reg_timeout:    -- Registrati
on for 'nmav1@192.168.240.34' timed out, trying again (Attempt ASTERISK-608)
[Apr  1 04:10:39] WARNING[916]: acl.c:548 ast_ouraddrfor: Cannot connect
REGISTER attempt 615 to nmav1@192.168.240.34

Comments:By: Nikos Mavrogianopoulos (nmav) 2009-07-21 03:56:40

The attached patch fixes the issue for me.

By: Olle Johansson (oej) 2009-09-04 01:59:55

Tell us more - which operating system are you running on?

By: Nikos Mavrogianopoulos (nmav) 2009-09-04 02:03:21

It is a linux kernel 2.6.11 with uclibc on arm.

By: Olle Johansson (oej) 2009-09-04 02:03:31

On OS/X the man page of sendto only defines -1 as a return value
"RETURN VALUES
    Upon successful completion, the number of bytes which were sent is returned.  Otherwise, -1 is returned and the global variable errno is set to
    indicate the error.

On centos 5.2:
"RETURN VALUE
      On success, these calls return the number of characters sent.  On error, -1 is returned, and errno is set appropriately."

On FreeBSD 7:
"RETURN VALUES
    The call returns the number of characters sent, or -1 if an error
    occurred."


So where does a -2 come from?

By: Olle Johansson (oej) 2009-09-04 02:04:24

Do you have man pages available? Check the sendto() function.

By: Nikos Mavrogianopoulos (nmav) 2009-09-04 03:20:23

The value -2 is clearly due to a bug (maybe the implementation returns the -errno instead of -1), so don't really bother with that... However the reschedule period was too low anyway. That's the main purpose of my patch. Rescheduling in 1ms has issues in slow cpus.

By: Olle Johansson (oej) 2009-09-04 04:38:00

I question that part of the code. If we have one of the failure above, why should we try again after one millisecond? That's seems wrong to me... This requires some further digging to find out when and why that code came into existance. There are SIP timers and stuff that handle that outside of this function. We should not have a special case for REGISTER requests, that messes up the hole excuse we have for transaction retransmit support.

grrrrrr.

By: Olle Johansson (oej) 2009-09-07 08:26:45

Sent mail to asterisk-dev to inquire about where this code is coming from and what it is trying to accomplish. It is removed from 1.6 - or never added.

By: Olle Johansson (oej) 2009-09-07 08:40:56

Ok, found explanation for this code in https://reviewboard.asterisk.org/r/132/

By: Olle Johansson (oej) 2009-09-08 11:31:29

putnopvut is going to revert the original commit.

By: Digium Subversion (svnbot) 2009-09-10 14:08:39

Repository: asterisk
Revision: 217668

U   branches/1.4/channels/chan_sip.c
U   branches/1.4/utils/Makefile

------------------------------------------------------------------------
r217668 | oej | 2009-09-10 14:08:39 -0500 (Thu, 10 Sep 2009) | 9 lines

Remove harmful code that causes endless loops.
Remove code that causes loops in registrations.

We have agreed that the patch that this code was part of was bad. I am ripping out the code that causes
the issue. putnopvut needs to check the rest of the patch, if it needs to be changed as well.

This solves the issue reported in ASTERISK-14502, but needs more work before we close it (as described above).


------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=217668

By: Digium Subversion (svnbot) 2009-09-10 14:10:17

Repository: asterisk
Revision: 217669

_U  trunk/

------------------------------------------------------------------------
r217669 | oej | 2009-09-10 14:10:17 -0500 (Thu, 10 Sep 2009) | 16 lines

Blocked revisions 217668 via svnmerge

........
r217668 | oej | 2009-09-10 21:07:24 +0200 (Tor, 10 Sep 2009) | 9 lines

Remove harmful code that causes endless loops.
Remove code that causes loops in registrations.

We have agreed that the patch that this code was part of was bad. I am ripping out the code that causes
the issue. putnopvut needs to check the rest of the patch, if it needs to be changed as well.

This solves the issue reported in ASTERISK-14502, but needs more work before we close it (as described above).


........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=217669

By: Olle Johansson (oej) 2009-09-10 15:07:35

Ok, Mark has reviewed the rest of the old commit and we're happy with this small change.

Closing this bug report.