[OpenSIPS-Users] LUA AVP issue?

Gledhill, James james.gledhill at sipstorm.com
Thu Jun 14 22:53:55 CEST 2012


I am testing the Lua module in hopes of being able to use it more later,
but am coming across some strange things.

 

Is this the best place to ask about it?  If not point me in the right
direction. 

 

AVP_set or AVP_get (in Lua module) seem to be getting data for/from
other AVP(s).

 

I have included enough code from opensips.cfg and the lua file to be
able to replicate this problem.  It happens 100% of the time. 

 

 I am using 

*	opensips 1.8
*	CentOS 5.8
*	Lua 5.1.4

 

=============

Opensips.cfg (partial file)

=============

 

## route[INVITE] is called for all invites - simple way to test :-)

route[INVITE] {

    xlog("In route_INVITE\n");

 

    $avp(abcde) = "bean";

    xlog("** ** avp(abcde) = $avp(abcde)\n");

 

    if ( lua_exec("invite") ) {     ## call the invite method in lua
file

        xlog("lua_exec returned TRUE\n");

    } else {

        xlog("lua_exec returned not true\n");

    }

 

    xlog("** ** avp(jimmy) = $avp(jimmy)\n");    ## this avp is
reporting the value set in lua to another avp ... WHY?

 

    sl_send_reply("486", "I am not answering now!");

    exit;

}

 

 

=============

Lua (partial file)

=============

 

function invite(param)

    xlog("**********     --->  INVITE test from lua -- getpid =" ..
getpid() .. "\n");

    -- AVP_get("jimmy") returns a null because it is not set - this is
expected.

    xlog("**********     --->  INVITE test from lua -- AVP_get(jimmy) ="
.. tostring(AVP_get("jimmy")) .. "\n");

 

    AVP_set("bingo","Old_mcDonald");

    xlog("**********     --->  INVITE test from lua -- AVP_get(bingo) ="
.. tostring(AVP_get("bingo")) .. "\n");

    xlog("**********     --->  INVITE test from lua -- AVP_get(abcde) ="
.. tostring(AVP_get("abcde")) .. "\n");

    xlog("**********     --->  INVITE test from lua -- AVP_get(fred) ="
.. tostring(AVP_get("fred")) .. "\n");

    -- NOW ... AVP_get("jimmy")  returns "Old_mcDonald" which is what
"bingo" is set to .. WHY IS avp(jimmy) returning this?

    xlog("**********     --->  INVITE test from lua -- AVP_get(jimmy) ="
.. tostring(AVP_get("jimmy")) .. "\n");

    xlog("**********     --->  INVITE test from lua -- filemtime =" ..
filemtime("/root/foo.dump") .. "\n");

 

    return 0;

end

 

 

=============

Output

=============

 

In route_INVITE

** ** avp(abcde) = bean

siplua: **********     --->  INVITE test from lua -- getpid =6269

siplua: **********     --->  INVITE test from lua -- AVP_get(jimmy) =nil

siplua: **********     --->  INVITE test from lua -- AVP_get(bingo)
=Old_mcDonald

siplua: **********     --->  INVITE test from lua -- AVP_get(abcde)
=bean

siplua: **********     --->  INVITE test from lua -- AVP_get(fred) =nil

siplua: **********     --->  INVITE test from lua -- AVP_get(jimmy)
=Old_mcDonald   <<HOW/WHY is this getting set?>>

siplua: **********     --->  INVITE test from lua -- filemtime
=1277825218

lua_exec returned TRUE

** ** avp(jimmy) = Old_mcDonald

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20120614/df985175/attachment-0001.htm>


More information about the Users mailing list