Skip to content

Commit

Permalink
Add code to troubleshoot some BUG report on weight sorting alg.
Browse files Browse the repository at this point in the history
Dump all the gws, their weights and the running sums, so we can undestand why the alg fails here - this dump will happen only when the bug is detected.
Also, in case of this BUG, avoid dropping the call (by return -1), but rather return something usefull, so the call can be routed further.

(cherry picked from commit 35cf96e)
  • Loading branch information
bogdan-iancu committed Aug 16, 2021
1 parent bb4de46 commit be14c99
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules/drouting/drouting.c
Expand Up @@ -2730,8 +2730,14 @@ static int weight_based_sort(pgw_list_t *pgwl, int size, unsigned short *idx)
for( i=first ; i<size ; i++ )
if (running_sum[i]>rand_no) break;
if (i==size) {
LM_CRIT("bug in weight sort\n");
return -1;
LM_CRIT("bug in weight sort, first=%u, size=%u, rand_no=%u, total weight=%u\n",
first, size, rand_no, weight_sum);
for(i=first; i<size;i++)
LM_CRIT("i %d, idx %u, weight %u, running sum %u\n",
i, idx[i], pgwl[idx[i]].weight, running_sum[i]);
/* try to recover here by picking the last gw */
i = size - 1;
// return -1;
}
} else {
/* randomly select index */
Expand Down

0 comments on commit be14c99

Please sign in to comment.