[Home]

Summary:ASTERISK-00929: [patch] chan_sip fails into setting the ipaddr of the mysql peer (sometimes)
Reporter:Matteo Brancaleoni (mbrancaleoni)Labels:
Date Opened:2004-01-28 05:52:51.000-0600Date Closed:2004-09-25 02:55:32
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) chan_sip.patch
Description:sometimes (like 1 call out of 10) a very strange behaviour happens using mysql friends: in sip_create_addr there's a call to mysql_peer that retrieves the data from the db and set peer addr, among others. but returning to sip_create_addr the ip address is 0.0.0.0 !
I mean... doing debug ater inet_aton(rowval[x], &p->addr.sin_addr); (line 730 into chan_sip) the ip addr is *always* correct... then the functions return to line 794... and here sometimes the p->addr.sin_addr is 0.0.0.0 ,even if before was correct... there must be something wrong, but I wasn't able to find out where.
I made that quick patch that uses a temp var to store the ipaddr and all works ok (just to make the addr assignment into create_addr and not mysql_peer).

the same routines into chan_iax2 doesn't have this problem at all.

any idea?
Comments:By: Olle Johansson (oej) 2004-01-28 15:28:53.000-0600

WHEN does this happen? At registration? Or dial out to peer?
mysql_peer sets dynamic=1

Hmmm. This is ugly. Please explain more.

By: Matteo Brancaleoni (mbrancaleoni) 2004-01-28 15:42:18.000-0600

* registrations : always ok, I can register without problems and on the db the values are stored correctly.

that happens when I dialout to the peer, but not always (like above 1 call out of 10) and is more regular if I wait at least 20 secs or more after the last succesfull call. the problem is on the peer side...

Here's the scenario:
* dialout to peer (I assume that call is ok)
-> case A: hangup and quickly redial... no probs. I can always dial the peer
-> case B: hangup, wait some time (30secs ?)... dial again... error.
  on __sip_xmit I see WARNINGs with IP addr == 0.0.0.0

so I did some debug.
since with mysql friends, every peer is dynamic and temponly, every time a sip peer is dialed sip_create_addr calls mysq_peer to get peer data
(the peer is registered, so I have all data, like ipaddr & port on the db).
So I added 2 ast_logs:
first in mysql_peer, dumping the ipaddr, after the assignment to the struct
second in sip_create_addr, just after mysql_peer is called, dumping the same
value (ip addr).
They must be the same.
when all is ok , they're the same.
when I get error, the first is ok, the second one is 0.0.0.0 !

but, if I use a temp var like a *char[20] into the peer struct, where I save
the string from the db in mysql_peer and in sip_create_addr I do the real assignment.... all is ok. (see my patch).

my workaround is solid, but still I cannot get why the ipaddr is lost somewhere going back from mysql_peer to sip_create_addr...

By: Rob Gagnon (rgagnon) 2004-02-23 16:01:14.000-0600

isn't the 0.0.0.0 simply being caused by an expired registration check following the read of data from the table?

Current cvs 1.299 shows:

if ((nowtime - regseconds) > default_expiry) memset(&p->addr, 0, sizeof(p->addr));

following the read of the data...

This problem might be fixed by bug ASTERISK-1011052

edited on: 02-24-04 11:10

By: z_smurf (z_smurf) 2004-02-23 16:48:07.000-0600

Yes, this is a fixed in ASTERISK-1011052.

By: Malcolm Davenport (mdavenport) 2004-02-24 15:02:13.000-0600

Changes made in CVS.  Thank you. :)