Hi Daniel,

when printing fscript only, there is no output line in the log. So I added the following code:

if(fscript == nil) then
        sr.log("warn","Filterscript is nil")
elseif(fscript == 0) then
        sr.log("warn","Filterscript is 0 n")
elseif(fscript == "0") then
        sr.log("warn","Filterscript is 0 s")
else
        sr.log("info","fscript found")
end

And the output is:

 WARNING: app_lua [app_lua_sr.c:99]: Filterscript is nil

So nothing is returned at all. But the htable entry is definitely set, because it works in some cases (without changing anything) and in some cases not. According to sht_dump, everything seems to be ok.

When using pv index like sr.pv.get("$(hdr(X-Test)["..i.."])") , a similar problem occurs (sometimes the value is returned, sometimes not). When omitting the pv index at all, it works everytime... So may the dynamic name of the variable is the problem? But (according to the debug message) the pv cache check function gets the correct name...

Cheers
Jasmin

Am 01.03.2013 17:49, schrieb Daniel-Constantin Mierla:
Hello,

On 3/1/13 3:40 PM, Jasmin Schnatterbeck wrote:
Hi,

when using sr.pv.get() in app_lua the pv value is not always returned.

Lua code is:

local fscript = sr.pv.get("$(sht(myscripts=>" .. args["filterid"] .."))")

    if(fscript) then
        sr.log("info","Filterscript is " .. fscript)
    else
        sr.log("warn","fscript not found!")
    end


And log shows:

app_lua [app_lua_sr.c:888]: pv get: (sht(myscripts=>1))
 <core> [pvapi.c:318]: pvar [$(sht(myscripts=>1))] found in cache
WARNING: app_lua [app_lua_sr.c:99]: fscript not found!

So the pv is being discovered in the pv cache, but sr.pv.get() returns
no value.

I think the problem occurs especially in the case, when using
sht_reload mi command. So I have had a short look into htable.c and I
did not find any code, that clears the pv cache... is that
necessary/may the reason for the problem, that pv is found in pv cache
but nothing returned? (kamailio 3.2.3)

Thanks for any ideas...
the cache is for PV names, not for PV values. What is printed as value
of fscript anyhow? It might get 0 which will result in same logic with IF.

Cheers,
Daniel


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to