Module: kamailio
Branch: master
Commit: a7693045df3c01e29d485aebeb21ccff3ed1ce96
URL:
https://github.com/kamailio/kamailio/commit/a7693045df3c01e29d485aebeb21ccf…
Author: Julien Chavanton <jchavanton(a)gmail.com>
Committer: GitHub <noreply(a)github.com>
Date: 2020-09-29T08:42:30-07:00
Merge pull request #2485 from kamailio/jchavanton/dispatcher
dispatcher: fix an error in initialisation
---
Modified: src/modules/dispatcher/dispatch.c
---
Diff:
https://github.com/kamailio/kamailio/commit/a7693045df3c01e29d485aebeb21ccf…
Patch:
https://github.com/kamailio/kamailio/commit/a7693045df3c01e29d485aebeb21ccf…
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index 4066bc39d7..8e798a871b 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -2588,6 +2588,8 @@ int ds_mark_dst(struct sip_msg *msg, int state)
}
static inline void latency_stats_update(ds_latency_stats_t *latency_stats, int latency)
{
+ int training_count = 10000;
+
/* after 2^21 ~24 days at 1s interval, the average becomes a weighted average */
if (latency_stats->count < 2097152) {
latency_stats->count++;
@@ -2602,8 +2604,10 @@ static inline void latency_stats_update(ds_latency_stats_t
*latency_stats, int l
latency_stats->average = latency;
latency_stats->estimate = latency;
}
- /* train the average if stable after 10 samples */
- if (latency_stats->count > 10 && latency_stats->stdev < 0.5)
latency_stats->count = 500000;
+ /* stabilize-train the estimator if the average is stable after 10 samples */
+ if (latency_stats->count > 10 && latency_stats->count <
training_count
+ && latency_stats->stdev < 0.5)
+ latency_stats->count = training_count;
if (latency_stats->min > latency)
latency_stats->min = latency;
if (latency_stats->max < latency)