Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions modules/drouting/drouting.c
Original file line number Diff line number Diff line change
Expand Up @@ -2997,9 +2997,9 @@ static int weight_based_sort(pgw_list_t *pgwl, int size, unsigned short *idx)
// return -1;
}
} else {
/* randomly select index */
// i = (unsigned int)((size-first)*((double)rand()/((double)RAND_MAX)));
i = first;
/* all remaining gateways have weight 0, treat them as equal
and randomly select one with uniform distribution */
i = first + (unsigned int)((size - first) * ((double)rand() / ((double)RAND_MAX + 1.0)));
}
LM_DBG("selecting element %d with weight %d\n",
idx[i], pgwl[ idx[i] ].weight);
Expand Down