[Kamailio-Users] Problems with counter $var(i)
Klaus Darilion
klaus.mailinglists at pernau.at
Thu Nov 13 19:58:58 CET 2008
Hi!
Be aware! Script variables
http://www.kamailio.org/dokuwiki/doku.php/pseudovariables:devel#script_variables
are global for a certain process - regardless of the failure route.
if you want a counter which belongs to a transaction you have to use
AVPs, e.g. $avp(i:1)
klaus
Ricardo Martinez schrieb:
> Hello
>
> I realized that the counter $var(i) in the failure_route[1] seems not to
> be resetting to 0 when the 2^nd , 3th ..etc call arrive.
>
> So for the second call I have the counter 0 in the main route, the
> route(3), route(1) but in the failure_route is set to 3 (the last
> values from the last call)
>
> I keep trying to figure it out why this is happening..
>
>
>
> Anyone?
>
>
>
> Thanks,
>
> Ricardo.-
>
>
>
>
>
> *De:* users-bounces at lists.kamailio.org
> [mailto:users-bounces at lists.kamailio.org] *En nombre de *Ricardo Martinez
> *Enviado el:* jueves, 13 de noviembre de 2008 11:46
> *Para:* users at lists.kamailio.org
> *Asunto:* [Kamailio-Users] Problems with counter $var(i)
>
>
>
> *Sorry ¡ i forgot to put the subject.*
>
>
>
> Hello list.
>
> I’m having some problems trying to build a counter for my kamailio.cfg file.
>
> This is what I have..
>
>
>
>
>
> main()
>
> …
>
> load avp from radius}
>
> var(i)=0;
>
> route(3);
>
> …
>
>
>
> route[1] {
>
>
>
> t_on_failure("1");
>
> if (!t_relay()) {
>
> sl_reply_error();
>
> };
>
> xlog("L_INFO","[$ci] $rm t_relay a $ru");
>
> exit;
>
> }
>
> route(3)
>
> …
>
> $var(nr)=$avp(s:caller_nr);
>
> If ( var(i) < $var(nr) );
>
> $var(i) = $var(i) + 1;
>
> route(1);
>
> else
>
> exit;
>
>
>
>
>
> failure_route[1] {
>
> xlog("L_INFO", "[$ci] $rm:$ru failure_route\n");
>
>
>
> if (t_was_cancelled()) {
>
> xlog("L_INFO", "[$ci] $rm:$ru t_was_cancelled en
> failure_route\n");
>
> exit;
>
> }
>
>
>
> if (!next_gw()) {
>
> xlog("L_INFO", "[$ci] No hay mas gateways para $rm:$ou\n");
>
> route(3);
>
> } else {
>
> xlog("L_INFO", "XXXXX");
>
> }
>
>
>
> t_on_failure("1");
>
> t_relay();
>
> }
>
>
>
>
>
> After I restart the service the first time a call arrives the counter
> seems to go OK, the counter goes from 0 to 2 (if the caller_nr=3). But
> the second time the $var(i) at the main and route(3) it’s = 0, but in
> the failure_route it keeps the value = 3. What I’m doing wrong?
>
> Can someone help me here?
>
>
>
> Thanks
>
>
>
> Ricardo Martinez.-
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.kamailio.org
> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
More information about the Users
mailing list