From be14c99e6f41e378df13c6f681fa7f098df4b25f Mon Sep 17 00:00:00 2001 From: Bogdan-Andrei Iancu Date: Mon, 16 Aug 2021 14:39:58 +0300 Subject: [PATCH] Add code to troubleshoot some BUG report on weight sorting alg. 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 35cf96e2cc3d9a0f1e280d47a5ff1ee526940bef) --- modules/drouting/drouting.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/drouting/drouting.c b/modules/drouting/drouting.c index 0e110887385..857fd8dd181 100644 --- a/modules/drouting/drouting.c +++ b/modules/drouting/drouting.c @@ -2730,8 +2730,14 @@ static int weight_based_sort(pgw_list_t *pgwl, int size, unsigned short *idx) for( i=first ; irand_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