<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span lang="NL">Hello Community,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="NL"><o:p> </o:p></span></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Background Information:<o:p></o:p></p>
<p class="MsoNormal">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).<o:p></o:p></p>
<p class="MsoNormal">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.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">On INVITE we do this:<o:p></o:p></p>
<p class="MsoNormal">$var(reference) = $uuid(g);<o:p></o:p></p>
<p class="MsoNormal">$sht(calls=>$ci) = $ci;<o:p></o:p></p>
<p class="MsoNormal">$sht(calls=>$ci::reference) = $var(reference);<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">On BYE/4XX,5XX,6XX, etc we did this:<o:p></o:p></p>
<p class="MsoNormal">sht_rm_name_re("calls=>$ci");<o:p></o:p></p>
<p class="MsoNormal">sht_rm_name_re("calls=>$ci::reference");<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">SIPP generates incremented call-id’s, like this: <a href="mailto:1-14875@1.0.0.1">
1-14875@1.0.0.1</a>. <o:p></o:p></p>
<p class="MsoNormal">When you generate enough calls, for instance 30 calls, the 21<sup>st</sup> call will have the call-id
<a href="mailto:21-14875@1.0.0.1">21-14875@1.0.0.1</a>.<o:p></o:p></p>
<p class="MsoNormal">If for instance the BYE for the call-id <a href="mailto:1-14875@1.0.0.1">
1-14875@1.0.0.1</a> arrives before <a href="mailto:21-14875@1.0.0.1">21-14875@1.0.0.1</a> , both htable entries will be removed by the sht_rm_name_re function, since it matches based on regex.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">To fix this we made sure the function matches on the exact keys by doing this:<o:p></o:p></p>
<p class="MsoNormal">$var(callid) = '^' + $ci + '$';<o:p></o:p></p>
<p class="MsoNormal">$var(callid_reference) = '^' + $ci + '::reference' + '$';<o:p></o:p></p>
<p class="MsoNormal">sht_rm_name_re("calls=>$var(callid)");<o:p></o:p></p>
<p class="MsoNormal">sht_rm_name_re("calls=>$var(callid_reference)");<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hope this may help someone in the future facing the same issue.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Grant Bagdasarian<o:p></o:p></p>
<p class="MsoNormal">CM<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>