[sr-dev] Lua sr.pv.get and htable pv problem

Ovidiu Sas osas at voipembedded.com
Thu Mar 14 17:15:06 CET 2013


Probably is related to this commit:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5fc59c44a6dbc97049a985b5b2f7280510b293b0
It should be fixed in 3.2 (pull from git 3.2 branch or latest 3.2.x
tarball  and test).

Regards,
Ovidiu Sas

-- 
VoIP Embedded, Inc.
http://www.voipembedded.com

On Thu, Mar 14, 2013 at 11:36 AM, Jasmin Schnatterbeck <js at data-cmr.net> wrote:
> Hi Daniel,
>
> that issue seems to be fixed in 3.3... may the corresponding commit is
> related to app_lua or pvapi.
>
> Cheers
> Jasmin
>
> Am 02.03.2013 04:06, schrieb Jasmin Schnatterbeck:
>
>> 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



More information about the sr-dev mailing list