Summary:ASTERISK-01448: [patch] Localize all find user, find peer, update peer calls to single functions, add mysql lookup ability to sip_devicestate()
Reporter:Rob Gagnon (rgagnon)Labels:
Date Opened:2004-04-21 17:41:03Date Closed:2004-09-25 02:49:40
Versions:Frequency of
Environment:Attachments:( 0) chan_sip.c.patch3.txt
Description:For future changes, and to solve an incomplete implementation of mysql into chan_sip.c, this patch moves all the while(){} blocks that find a SIP user or SIP peer into a single function for each purpose.

This allows for easier modification in the future when another database engine or something needs to hook on the lookups.

Also, the sip_devicestate() function never would hit the mysql database for any of its peer lookups that it does.


There is still an issue of the MWI notifications in do_monitor() but we can work on that in the future.
Comments:By: exomorph (exomorph) 2004-04-21 17:57:35

Tested here, and its working for me.  Got my vote.

By: Rob Gagnon (rgagnon) 2004-04-21 18:46:06

It worked, but I found a possible memory leak for ACL's under peers not being free'd.

Also for peer's found with temponly==1, but ACL does not allow, the peer and its ACL would not be free'd.

chan_sip.c.patch2.txt solves that problem

By: exomorph (exomorph) 2004-04-22 13:40:23

Checked the new patch... Still works for me. :)

By: Olle Johansson (oej) 2004-04-22 14:34:48

Thank you for changing the name of find_user - I've never understood that. Also, thank you for finding the missing of ast_free_ha. Another leak fixed.

Seems OK for me. I'll integrate this into chan_sip2 soon. Haven't got time to test.

By: Rob Gagnon (rgagnon) 2004-04-22 15:14:06

removed an empty if statement, and changed all comments to standard /* */ pairs from the cheap // versions.

By: Olle Johansson (oej) 2004-04-23 02:33:35

While fixing this, we might as well look into how we match incoming calls from peers, when we match on IP address. Mark rewrote the matching on IAX2 recently and that got me thinking.

We really should try to match on *peer names* first. If all of those fails, we need to check for *all* matches on IP address. If only one matches, we got a hit. If we have multiple matches there's a problem and we should fail.

What do you think?

By: exomorph (exomorph) 2004-04-26 11:10:31

Patch submitted to cvs-head.