[Kamailio-Users] freeing innername from htable Re: perl module, "pv_sprintf: Memory exhausted!"
Mik Cheez
michael_bulk at wildgate.com
Tue Jun 9 18:00:56 CEST 2009
Christian,
Not sure if this will help you, but it's a good starting point if you want
to use Perl. I grab a good deal of information using the headers and AVP's
in order to write data to a MSSQL database and do LCR. Here's essentially
how I grab the values:
#Begin
use strict;
use OpenSER qw ( log );
use OpenSER::Constants;
use OpenSER::Message;
Sub your_function {
# get headers
my $m = shift;
my ($lrn, $inrpid);
# Headers
my $ruri = $m->getHeader("To");
# Pseudo Variables
my $source_ip = $m->pseudoVar("\$si");
my $in_ANI = $m->pseudoVar("\$fU");
my $insrc = $m->pseudoVar("\$fd");
my $daytim = $m->pseudoVar("\$Tf");
my $callid = $m->pseudoVar("\$ci");
# Check if PV's are set
if( $m->pseudoVar("\$re") != undef ){
$inrpid = $m->pseudoVar("\$re");
}
# AVP's
if( OpenSER::AVP::get(60) != undef ){
$lrn = OpenSER::AVP::get(60);
}
# Write some data to the log
log(L_INFO, sprintf("callid: %s\n", $callid));
# DO WHATEVER ELSE
}
# END
You can set AVP's in your script before calling the function:
$avp(my_AVP) = $sht(a=>$tu-translate);
Mik
-----Original Message-----
From: users-bounces at lists.kamailio.org
[mailto:users-bounces at lists.kamailio.org] On Behalf Of Christian Koch
Sent: Tuesday, June 09, 2009 6:56 AM
To: Daniel-Constantin Mierla
Cc: users at lists.kamailio.org
Subject: Re: [Kamailio-Users] freeing innername from htable Re: perl module,
"pv_sprintf: Memory exhausted!"
Hello Daniel,
Daniel-Constantin Mierla schrieb:
> unfortunately you cannot use $sht in this way from perl module. The
> same limitation that prevent calling any function from modules apply
> here -- the fixup system used at startup, when string parameters are
> pre-compiled in different forms to speed up runtime execution.
So there is no way to access $sht from other moduls (like perl or xlog)?
It seems to work, but obviously the memory isn't freed :-)
What we are trying to do is the following:
During processing of "INVITE" we need to save some call details (source
IP, URI, ...) and want to write them to file when the call is finished
(including duration, ...), while processing BYE or CANCEL, to have CDRs.
As there are multiple childs of kamailio we tried to save the calls
details from the INVITE in shared memory using htable (e.g.
"$sht(a=>$ci::srcip) = $si"), so we can use them while processing the
BYE (possibly in another child). There we wanted to use perl to be able
to write the saved details to a file.
We used the shared memory module as we don´t want to save the infos to
DB because of performance issues we suspect when using DBs.
But as you mentioned $sht is not supposed to be used in such a way. Do
you have any idea what else we can do to generate CDRs as mentioned?
By using other modules for example or a complete other way you may know?
>
> It can be added as a feature request for future. For module functions
> I added the core support for free fixup functions, but nobody
> committed to continue the work in perl module.
>
> If you want to work on it, I can assist and guide you.
Well, honestly we are looking for a fast way to implement it.
How long will it take to implement it with your guidance?
Thanks and regards,
Christian
_______________________________________________
Kamailio (OpenSER) - Users mailing list
Users at lists.kamailio.org
http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
More information about the sr-users
mailing list