Hello Community,
We were facing a weird issue in one of our Kamailio servers where custom htable entries were removed which did not belong to a particular call.
Background Information: We use htable to store the call-id and a uuid when an INVITE message is received and remove these entries when the call is completed/failed (so on CANCEL, BYE, 4XX, 5XX, 6XX, etc). In this case the function sht_rm_name_re was causing incremented call-id's belonging to different calls to be removed from the htable, since the removal is based on regex and not the exact key.
On INVITE we do this: $var(reference) = $uuid(g); $sht(calls=>$ci) = $ci; $sht(calls=>$ci::reference) = $var(reference);
On BYE/4XX,5XX,6XX, etc we did this: sht_rm_name_re("calls=>$ci"); sht_rm_name_re("calls=>$ci::reference");
SIPP generates incremented call-id's, like this: 1-14875@1.0.0.1mailto:1-14875@1.0.0.1. When you generate enough calls, for instance 30 calls, the 21st call will have the call-id 21-14875@1.0.0.1mailto:21-14875@1.0.0.1. If for instance the BYE for the call-id 1-14875@1.0.0.1mailto:1-14875@1.0.0.1 arrives before 21-14875@1.0.0.1mailto:21-14875@1.0.0.1 , both htable entries will be removed by the sht_rm_name_re function, since it matches based on regex.
To fix this we made sure the function matches on the exact keys by doing this: $var(callid) = '^' + $ci + '$'; $var(callid_reference) = '^' + $ci + '::reference' + '$'; sht_rm_name_re("calls=>$var(callid)"); sht_rm_name_re("calls=>$var(callid_reference)");
Hope this may help someone in the future facing the same issue.
Regards,
Grant Bagdasarian CM