[SR-Users] Problem with callid as htable key

jenus at cyberchaos.nl jenus at cyberchaos.nl
Tue Oct 16 10:03:34 CEST 2018


Daniel,

Thanks for the quick response, that indeed solves my problem.


Jan

Daniel-Constantin Mierla schreef op 2018-10-16 09:55:
> Hello,
> 
> the expression in the $shtcn(table=>exp) can have some operators at the
> beginning, see:
> 
>   -
> https://www.kamailio.org/wiki/cookbooks/devel/pseudovariables#shtcn_htable_exp
> 
> So, eq is one of them, the safest is to explicitly set the operator if
> you cannot predict what is the key, like in this case. If the operator
> is missing, then the exp is matched as regular expression, so you can 
> do:
> 
> $shtcn(ht_test=>~~$var(htid))
> 
> Cheers,
> Daniel
> 
> 
> On 16.10.18 09:47, jenus at cyberchaos.nl wrote:
>> Hello,
>> 
>> I'm running kamailio 5.1.4 and running into a issue with htable. I use
>> it to store some dialog data so i can use it in a http route. When i
>> use the callid as a key it creates a issue for callid's starting with
>> eq. Here some example code that i use to reproduce the issue:
>> 
>> 
>> modparam("htable", "htable", "ht_test=>size=16;autoexpire=10")
>> 
>> $var(htable-val) = $_s($dlg(h_entry)) + "::" + $_s($dlg(h_id)) + "::"
>> + $Ts;
>> xlog("L_WARN", "HT_TEST: Adding $var(htable-val) to ht_test with key
>> eq1234");
>> $var(htid) = "eq1234";
>> $sht(ht_test=>$var(htid)) =  $var(htable-val);
>> $var(htable-val) = $null;
>> 
>> if ($shtcn(ht_test=>$var(htid)) > 0)
>> {
>>        xlog("L_WARN", "HT_TEST: Key eq1234 found!");
>> } else {
>>        xlog("L_WARN", "HT_TEST: Key eq1234 NOT found!");
>> }
>> $var(htid) = $null;
>> 
>> Results in :
>> 
>> Oct 16 09:36:31 sip03 /usr/sbin/kamailio[22344]: WARNING: <script>:
>> HT_TEST: Adding 531::926::1539675391 to ht_test with key eq1234
>> Oct 16 09:36:31 sip03 /usr/sbin/kamailio[22344]: WARNING: <script>:
>> HT_TEST: Key eq1234 NOT found!
>> 
>> 
>> When i prefix eq with a 1 it works fine:
>> 
>> modparam("htable", "htable", "ht_test=>size=16;autoexpire=10")
>> 
>> $var(htable-val) = $_s($dlg(h_entry)) + "::" + $_s($dlg(h_id)) + "::"
>> + $Ts;
>> xlog("L_WARN", "HT_TEST: Adding $var(htable-val) to ht_test with key
>> eq1234");
>> $var(htid) = "1eq1234";
>> $sht(ht_test=>$var(htid)) =  $var(htable-val);
>> $var(htable-val) = $null;
>> 
>> if ($shtcn(ht_test=>$var(htid)) > 0)
>> {
>>        xlog("L_WARN", "HT_TEST: Key eq1234 found!");
>> } else {
>>        xlog("L_WARN", "HT_TEST: Key eq1234 NOT found!");
>> }
>> $var(htid) = $null;
>> 
>> Results in:
>> 
>> Oct 16 09:37:25 sip03 /usr/sbin/kamailio[22555]: WARNING: <script>:
>> HT_TEST: Adding 3050::1098::1539675445 to ht_test with key eq1234
>> Oct 16 09:37:25 sip03 /usr/sbin/kamailio[22555]: WARNING: <script>:
>> HT_TEST: Key eq1234 found!
>> 
>> 
>> Am i running into a bug? Or are there some restrictions on the key's i
>> can use? I'm still going trough the logs to check if there are more
>> callid's that have a issue with matching.
>> 
>> 
>> Thanks,
>> 
>> Jan Hazenberg
>> 
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> sr-users at lists.kamailio.org
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users




More information about the sr-users mailing list