Module: kamailio
Branch: master
Commit: 851a839b50296669523947e1a0d73f1b602f0819
URL:
https://github.com/kamailio/kamailio/commit/851a839b50296669523947e1a0d73f1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-06-10T13:09:26+02:00
dispatcher: compare time interval validity for oveload control
---
Modified: src/modules/dispatcher/dispatch.c
---
Diff:
https://github.com/kamailio/kamailio/commit/851a839b50296669523947e1a0d73f1…
Patch:
https://github.com/kamailio/kamailio/commit/851a839b50296669523947e1a0d73f1…
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index c7722acb32e..6e13987a4da 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -498,18 +498,26 @@ int ds_oc_set_attrs(sip_msg_t *msg, int setid, str *duri, int irval,
int itval)
*/
static inline int ds_oc_skip(ds_set_t *dsg, int alg, int n)
{
- int ret = 0;
+ struct timeval tnow;
if(alg != DS_ALG_OVERLOAD) {
return 0;
}
+ gettimeofday(&tnow, NULL);
+
+ if(timercmp(&dsg->dlist[n].octime, &tnow, <)) {
+ /* over the time interval validity - use it */
+ return 0;
+ }
if(dsg->dlist[n].ocdist[dsg->dlist[n].ocidx] == 1) {
- ret = 0;
+ /* use it */
+ return 0;
}
dsg->dlist[n].ocidx = (dsg->dlist[n].ocidx + 1) % 100;
- return ret;
+ /* skip it */
+ return 1;
}
/**