summaryrefslogtreecommitdiffstats
path: root/src/libutil/upstream.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-11-01 15:18:33 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-11-01 15:18:33 +0000
commitcd597be6acdd134cd5be598ff810aea5d8ff32be (patch)
tree484b77d1dbd677b6030776c43d2f06a7950d3283 /src/libutil/upstream.c
parent0ed9dcd1e64f921eb6682cfdb9948384d8bdb8bb (diff)
downloadrspamd-cd597be6acdd134cd5be598ff810aea5d8ff32be.tar.gz
rspamd-cd597be6acdd134cd5be598ff810aea5d8ff32be.zip
Add jitter for upstream reviving.
Diffstat (limited to 'src/libutil/upstream.c')
-rw-r--r--src/libutil/upstream.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c
index 070ff3858..b4d341dac 100644
--- a/src/libutil/upstream.c
+++ b/src/libutil/upstream.c
@@ -70,6 +70,7 @@ static struct event_base *ev_base = NULL;
/* 4 errors in 10 seconds */
const guint default_max_errors = 4;
const guint default_revive_time = 60;
+const gdouble default_revive_jitter = 0.4;
const guint default_error_time = 10;
const gdouble default_dns_timeout = 1.0;
const guint default_dns_retransmits = 2;
@@ -210,7 +211,9 @@ rspamd_upstream_set_inactive (struct upstream_list *ls, struct upstream *up)
if (ev_base != NULL) {
event_base_set (ev_base, &up->ev);
}
- up->tv.tv_sec = default_revive_time;
+
+ up->tv.tv_sec = default_revive_time + ottery_rand_range (
+ default_revive_time * default_revive_jitter);
up->tv.tv_usec = 0;
event_add (&up->ev, &up->tv);