diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-25 12:15:16 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-25 12:15:16 +0100 |
commit | 052323f56f5dad1ccbb2e819983b532d0cd7db34 (patch) | |
tree | 45715c153ea25f85ea1859fbc83016107631576c /src | |
parent | 2a0e17496bd3d81b8df017ba414cb91efd3e58a8 (diff) | |
download | rspamd-052323f56f5dad1ccbb2e819983b532d0cd7db34.tar.gz rspamd-052323f56f5dad1ccbb2e819983b532d0cd7db34.zip |
[Minor] Try to fix HTTP maps check timeouts
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/map.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/libutil/map.c b/src/libutil/map.c index 7d8443d08..4c121f580 100644 --- a/src/libutil/map.c +++ b/src/libutil/map.c @@ -1007,31 +1007,35 @@ rspamd_map_schedule_periodic (struct rspamd_map *map, if (map->next_check != 0) { timeout = map->next_check - rspamd_get_calendar_ticks (); - if (timeout < map->poll_timeout) { - timeout = map->poll_timeout; + if (timeout > 0 && timeout < map->poll_timeout) { + /* Early check case, jitter */ + gdouble poll_timeout = map->poll_timeout; if (errored) { - timeout = map->poll_timeout * error_mult; + poll_timeout = map->poll_timeout * error_mult; } else if (locked) { - timeout = map->poll_timeout * lock_mult; + poll_timeout = map->poll_timeout * lock_mult; } - jittered_sec = rspamd_time_jitter (timeout, 0); + jittered_sec = MIN (timeout, poll_timeout); + } + else if (timeout <= 0) { + /* Data is already expired, need to check */ + jittered_sec = 0.0; } else { - jittered_sec = rspamd_time_jitter (timeout, map->poll_timeout); + /* No need to check now, wait till next_check */ + jittered_sec = timeout; } - - /* Reset till the next usage */ - map->next_check = 0; } else { timeout = map->poll_timeout; if (initial) { timeout = 0.0; - } else { + } + else { if (errored) { timeout = map->poll_timeout * error_mult; } |