Module: kamailio
Branch: 5.2
Commit: c1eaf3353f43d34f164f28a871399ca785c40b4f
URL:
https://github.com/kamailio/kamailio/commit/c1eaf3353f43d34f164f28a871399ca…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-08-12T20:18:12+02:00
dispatcher: skip inactive destinations for pointing next to be used record
(cherry picked from commit 18eeda012a711584239b03d5cfef8b7720f0ef31)
---
Modified: src/modules/dispatcher/dispatch.c
---
Diff:
https://github.com/kamailio/kamailio/commit/c1eaf3353f43d34f164f28a871399ca…
Patch:
https://github.com/kamailio/kamailio/commit/c1eaf3353f43d34f164f28a871399ca…
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index 372adda056..cdec4843eb 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -2026,6 +2026,7 @@ int ds_manage_routes(sip_msg_t *msg, ds_select_state_t *rstate)
int i;
unsigned int hash;
ds_set_t *idx = NULL;
+ int ulast = 0;
if(msg == NULL) {
LM_ERR("bad parameters\n");
@@ -2082,6 +2083,7 @@ int ds_manage_routes(sip_msg_t *msg, ds_select_state_t *rstate)
case DS_ALG_ROUNDROBIN: /* 4 - round robin */
hash = idx->last;
idx->last = (idx->last + 1) % idx->nr;
+ ulast = 1;
break;
case DS_ALG_HASHAUTHUSER: /* 5 - hash auth username */
i = ds_hash_authusername(msg, &hash);
@@ -2093,6 +2095,7 @@ int ds_manage_routes(sip_msg_t *msg, ds_select_state_t *rstate)
/* No Authorization found: Use round robin */
hash = idx->last;
idx->last = (idx->last + 1) % idx->nr;
+ ulast = 1;
break;
default:
LM_ERR("can't get authorization hash\n");
@@ -2194,6 +2197,11 @@ int ds_manage_routes(sip_msg_t *msg, ds_select_state_t *rstate)
rstate->emode = 1;
}
+ /* update last field for next select to point after the current active used */
+ if(ulast) {
+ idx->last = (hash + 1) % idx->nr;
+ }
+
LM_DBG("selected [%d-%d-%d/%d] <%.*s>\n", rstate->alg,
rstate->setid,
rstate->umode, hash,
idx->dlist[hash].uri.len, idx->dlist[hash].uri.s);