I made a few more changes to my code and tested some more and now the problem has gone away and I can no longer replicate it. Perhaps it is just something I do not fully understand about AVPs or opensips or the lua implementation. I was able to reproduce it 100% of the time for a while, but now can not - strange!
Any thoughts what happened in the original post? ________________________________ From: [email protected] [mailto:[email protected]] On Behalf Of Gledhill, James Sent: Thursday, June 14, 2012 3:54 PM To: [email protected] Subject: [OpenSIPS-Users] LUA AVP issue? 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
_______________________________________________ Users mailing list [email protected] http://lists.opensips.org/cgi-bin/mailman/listinfo/users
