Module: kamailio
Branch: master
Commit: 18eeda012a711584239b03d5cfef8b7720f0ef31
URL: 
https://github.com/kamailio/kamailio/commit/18eeda012a711584239b03d5cfef8b7720f0ef31

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2019-08-12T20:15:17+02:00

dispatcher: skip inactive destinations for pointing next to be used record

---

Modified: src/modules/dispatcher/dispatch.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/18eeda012a711584239b03d5cfef8b7720f0ef31.diff
Patch: 
https://github.com/kamailio/kamailio/commit/18eeda012a711584239b03d5cfef8b7720f0ef31.patch

---

diff --git a/src/modules/dispatcher/dispatch.c 
b/src/modules/dispatcher/dispatch.c
index 3d1098c462..43a7c8b8b2 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -2023,6 +2023,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");
@@ -2079,6 +2080,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);
@@ -2090,6 +2092,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");
@@ -2191,6 +2194,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);


_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to