Module: kamailio Branch: master Commit: 883f9cd0bf5a16dbc94556dfb84b806bbc2cba7e URL: https://github.com/kamailio/kamailio/commit/883f9cd0bf5a16dbc94556dfb84b806b...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2025-07-03T08:05:56+02:00
dispatcher: new dispatching algorithm 14
- serial or round-robin if the priority is the same for all destinations in the group and it is greater than 0
---
Modified: src/modules/dispatcher/dispatch.c Modified: src/modules/dispatcher/dispatch.h
---
Diff: https://github.com/kamailio/kamailio/commit/883f9cd0bf5a16dbc94556dfb84b806b... Patch: https://github.com/kamailio/kamailio/commit/883f9cd0bf5a16dbc94556dfb84b806b...
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c index 4a5c2d90cf8..50865a0d1f6 100644 --- a/src/modules/dispatcher/dispatch.c +++ b/src/modules/dispatcher/dispatch.c @@ -82,6 +82,7 @@ #define DS_ALG_RELWEIGHT 11 #define DS_ALG_PARALLEL 12 #define DS_ALG_LATENCY 13 +#define DS_ALG_RRSERIAL 14 #define DS_ALG_OVERLOAD 64 /* 2^6 - can be also used as a flag */
#define DS_HN_SIZE 256 @@ -778,7 +779,13 @@ ds_dest_t *add_dest2list(int id, str uri, int flags, int priority, str *attrs,
if(sp->dlist == NULL) { sp->dlist = dp; + if(priority > 0) { + sp->rrserial = priority; + } } else { + if(sp->rrserial > 0 && sp->rrserial != priority) { + sp->rrserial = 0; + } dp1 = NULL; dp0 = sp->dlist; /* highest priority last -> reindex will copy backwards */ @@ -2563,6 +2570,7 @@ int ds_manage_routes(sip_msg_t *msg, ds_select_state_t *rstate) ds_set_t *idx = NULL; int ulast = 0; int vlast = 0; + int valg = 0; int xavp_filled = 0;
if(msg == NULL) { @@ -2589,10 +2597,20 @@ int ds_manage_routes(sip_msg_t *msg, ds_select_state_t *rstate) return -1; }
+ if(rstate->alg == DS_ALG_RRSERIAL) { + /* decide on round-robin or serial dispatching */ + if(idx->rrserial != 0) { + valg = DS_ALG_ROUNDROBIN; + } else { + valg = DS_ALG_SERIAL; + } + } else { + valg = rstate->alg; + } LM_DBG("set [%d]\n", rstate->setid);
hash = 0; - switch(rstate->alg) { + switch(valg) { case DS_ALG_HASHCALLID: /* 0 - hash call-id */ if(ds_hash_callid(msg, &hash) != 0) { LM_ERR("can't get callid hash\n"); @@ -2707,6 +2725,7 @@ int ds_manage_routes(sip_msg_t *msg, ds_select_state_t *rstate) return -1; xavp_filled = 1; break; + /* case DS_ALG_RRSERIAL: // 14 - round-robin or serial decided above */ case DS_ALG_OVERLOAD: /* 64 - round robin with overload control */ lock_get(&idx->lock); hash = idx->last; diff --git a/src/modules/dispatcher/dispatch.h b/src/modules/dispatcher/dispatch.h index ffaab7cb7e8..d48b6347d45 100644 --- a/src/modules/dispatcher/dispatch.h +++ b/src/modules/dispatcher/dispatch.h @@ -270,6 +270,7 @@ typedef struct _ds_set { unsigned int rwlist[100]; struct _ds_set *next[2]; int longer; + int rrserial; /*!< round-robin or serial flag */ gen_lock_t lock; } ds_set_t;