<p>The lock was set to 0 else it would have been 48 times 2</p>
<pre><code>   /* if the array was not completely filled (i.e., the sum of rweights is
    * less than 100 due to truncated), then use last address to fill the rest */
   unsigned int last_insert =
         t > 0 ? dset->rwlist[t - 1] : (unsigned int)(dset->nr - 1);
   for(j = t; j < 100; j++)
      dset->rwlist[j] = last_insert;

   /* shuffle the content of the array in order to mix the selection
    * of the addresses (e.g., if first address has weight=20, avoid
    * sending first 20 calls to it, but ensure that within a 100 calls,
    * 20 go to first address */
   shuffle_uint100array(dset->rwlist);
   lock_release(&dset->lock);
   return 0;
}
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/1649#issuecomment-423610648">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZRZaXx3r6HoJCE0donhMdmNHJb4-ks5udR9-gaJpZM4W0cas">mute the thread</a>.<img src="https://github.com/notifications/beacon/AF36ZcWCDgGnyxXrmmIil4noclDcspIZks5udR9-gaJpZM4W0cas.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"PERSON","message":"@jchavanton in #1649: The lock was set to 0 else it would have been 48 times 2\r\n\r\n```\r\n   /* if the array was not completely filled (i.e., the sum of rweights is\r\n    * less than 100 due to truncated), then use last address to fill the rest */\r\n   unsigned int last_insert =\r\n         t \u003e 0 ? dset-\u003erwlist[t - 1] : (unsigned int)(dset-\u003enr - 1);\r\n   for(j = t; j \u003c 100; j++)\r\n      dset-\u003erwlist[j] = last_insert;\r\n\r\n   /* shuffle the content of the array in order to mix the selection\r\n    * of the addresses (e.g., if first address has weight=20, avoid\r\n    * sending first 20 calls to it, but ensure that within a 100 calls,\r\n    * 20 go to first address */\r\n   shuffle_uint100array(dset-\u003erwlist);\r\n   lock_release(\u0026dset-\u003elock);\r\n   return 0;\r\n}\r\n```"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1649#issuecomment-423610648"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/1649#issuecomment-423610648",
"url": "https://github.com/kamailio/kamailio/issues/1649#issuecomment-423610648",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "Re: [kamailio/kamailio] dispatcher algorithm 11 with congestion control memory corruption problem (#1649)",
"sections": [
{
"text": "",
"activityTitle": "**Julien Chavanton**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@jchavanton",
"facts": [

]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1649,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close issue",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1649\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/kamailio/kamailio/issues/1649#issuecomment-423610648"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 382846636\n}"
}
],
"themeColor": "26292E"
}
]</script>