diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-11-26 22:36:40 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-11-26 22:36:40 +0000 |
commit | f95d624720c6a3c4a02256221dab2f4551f3abef (patch) | |
tree | d14c014f1d51aedd67704570dc990f2284f3bdeb /src/libutil/upstream.c | |
parent | cc52edf62c9d0e56dcde76d7b070af48142e21a8 (diff) | |
download | rspamd-f95d624720c6a3c4a02256221dab2f4551f3abef.tar.gz rspamd-f95d624720c6a3c4a02256221dab2f4551f3abef.zip |
[Minor] Add probabilistic reset of errors in upstream addrs
Diffstat (limited to 'src/libutil/upstream.c')
-rw-r--r-- | src/libutil/upstream.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c index fa1c75286..5d421b212 100644 --- a/src/libutil/upstream.c +++ b/src/libutil/upstream.c @@ -236,7 +236,7 @@ static void rspamd_upstream_update_addrs (struct upstream *up) { guint addr_cnt, i, port; - gboolean seen_addr; + gboolean seen_addr, reset_errors = FALSE; struct upstream_inet_addr_entry *cur, *tmp; GPtrArray *new_addrs; struct upstream_addr_elt *addr_elt, *naddr; @@ -257,6 +257,11 @@ rspamd_upstream_update_addrs (struct upstream *up) addr_cnt++; } + /* At 10% probability reset errors on addr elements */ + if (rspamd_random_double_fast () > 0.9) { + reset_errors = TRUE; + } + new_addrs = g_ptr_array_new_full (addr_cnt, rspamd_upstream_addr_elt_dtor); /* Copy addrs back */ @@ -270,7 +275,7 @@ rspamd_upstream_update_addrs (struct upstream *up) if (rspamd_inet_address_compare (addr_elt->addr, cur->addr) == 0) { naddr = g_malloc0 (sizeof (*addr_elt)); naddr->addr = cur->addr; - naddr->errors = addr_elt->errors; /* Preserve errors */ + naddr->errors = reset_errors ? 0 : addr_elt->errors; seen_addr = TRUE; break; |