[OpenSIPS-Devel] [ opensips-Patches-3599314 ] Make perlvdb work with alias_db and without leaks

SourceForge.net noreply at sourceforge.net
Tue Jan 15 19:06:50 CET 2013


Patches item #3599314, was opened at 2013-01-03 04:39
Message generated for change (Comment added) made by bogdan_iancu
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086412&aid=3599314&group_id=232389

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: trunk
Status: Open
Resolution: Accepted
Priority: 5
Private: No
Submitted By: bratner (ratner2)
Assigned to: Bogdan-Andrei Iancu (bogdan_iancu)
Summary: Make perlvdb work with alias_db and without leaks

Initial Comment:
Several fixes:
1. change the the declared module name to db_perlvdb. Otherwise it is not found as db_ module. 
2. change the init db url type to actually be str
3. many changes that fix various memory leaks (perl object leaks)
4. fix result cleanup memory leaks

What works: Probably anything that does only query.
I use it for alias_db like this:
in opensips.cfg#perl stuff
loadmodule "perl.so"
modparam("perl", "modpath", "/usr/lib/opensips/perl")
modparam("perl", "filename", "/usr/lib/opensips/perl/vdbtest.pm")
loadmodule "perlvdb.so"

#alias lookup module 
loadmodule "alias_db.so"
modparam("alias_db", "db_url", "perlvdb:OpenSIPS::VDB::Adapter::Alias")
...
...
alias_db_lookup("OpenSIPS::VDB::VTab::MyCode","d" );  # Lookup the new user at domain for the incoming RURI
....

in /usr/lib/opensips/perl/vdbtest.pm:

use OpenSIPS::VDB::Adapter::Alias;
use OpenSIPS::VDB::VTab::MyCode;
use OpenSIPS;
1;

in /usr/lib/opensips/perl/OpenSIPS/VDB/VTab/MyCode.pm:

package OpenSIPS::VDB::VTab::MyCode;
@ISA = qw ( OpenSIPS::VDB::VTab OpenSIPS::Utils::Debug );
use OpenSIPS;
sub init {
        OpenSIPS::log(L_NOTICE, "Init in MyCode");
}



sub query {
        OpenSIPS::log(L_NOTICE, "Query in MyCode");
        my $self = shift;
        my $alias_username = shift;
        my $alias_domain = shift;
        OpenSIPS::log(L_NOTICE, "Finishing up the query in CP");
        return { username => "newuser", domain => "newdomain" };

}


1;


Any comments, bugs, requests to ratner2 at gmail.com





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

>Comment By: Bogdan-Andrei Iancu (bogdan_iancu)
Date: 2013-01-15 10:06

Message:
module name also changed - an overall testing would be appreciated. 

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

Comment By: Bogdan-Andrei Iancu (bogdan_iancu)
Date: 2013-01-15 08:29

Message:
BTW, please test my change in db init and confirm if ok

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

Comment By: Bogdan-Andrei Iancu (bogdan_iancu)
Date: 2013-01-15 08:29

Message:
I uploaded the patch to trunk only (it may need more testing before moving
to stable 1.8). I had to change the init db function as the change char ->
str was not correct - the processing inside the function was still
expecting a CHAR (nul terminated) -> this may have lead to memory
overflow.

I will also rename the whole module to db_perlvdb

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086412&aid=3599314&group_id=232389



More information about the Devel mailing list