aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/upstream.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-13 13:58:09 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-13 13:58:09 +0000
commit684996ee80c4b834f10c764a71a7f22dd2f23f83 (patch)
tree54ebf01447ac6fa4e693d00a952cda580884fd16 /src/libutil/upstream.c
parent54e835fc3540cc4dae025976fd15a0ad9cf10833 (diff)
downloadrspamd-684996ee80c4b834f10c764a71a7f22dd2f23f83.tar.gz
rspamd-684996ee80c4b834f10c764a71a7f22dd2f23f83.zip
[Minor] Add failure reason in the upstreams code
Diffstat (limited to 'src/libutil/upstream.c')
-rw-r--r--src/libutil/upstream.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c
index 94d694d77..7d8b81048 100644
--- a/src/libutil/upstream.c
+++ b/src/libutil/upstream.c
@@ -735,13 +735,19 @@ rspamd_upstream_set_inactive (struct upstream_list *ls, struct upstream *upstrea
}
void
-rspamd_upstream_fail (struct upstream *upstream, gboolean addr_failure)
+rspamd_upstream_fail (struct upstream *upstream,
+ gboolean addr_failure,
+ const gchar *reason)
{
gdouble error_rate = 0, max_error_rate = 0;
gdouble sec_last, sec_cur;
struct upstream_addr_elt *addr_elt;
struct upstream_list_watcher *w;
+ msg_debug_upstream ("upstream %s failed; reason: %s",
+ upstream->name,
+ reason);
+
if (upstream->ctx && upstream->active_idx != -1) {
sec_cur = rspamd_get_ticks (FALSE);
@@ -780,27 +786,38 @@ rspamd_upstream_fail (struct upstream *upstream, gboolean addr_failure)
if (error_rate > max_error_rate) {
/* Remove upstream from the active list */
if (upstream->ls->ups->len > 1) {
- msg_debug_upstream ("mark upstream %s inactive: %.2f "
+ msg_debug_upstream ("mark upstream %s inactive; "
+ "reason: %s; %.2f "
"error rate (%d errors), "
"%.2f max error rate, "
"%.1f first error time, "
"%.1f current ts, "
"%d upstreams left",
- upstream->name, error_rate, upstream->errors,
- max_error_rate, sec_last, sec_cur,
+ upstream->name,
+ reason,
+ error_rate,
+ upstream->errors,
+ max_error_rate,
+ sec_last,
+ sec_cur,
upstream->ls->alive->len - 1);
rspamd_upstream_set_inactive (upstream->ls, upstream);
upstream->errors = 0;
}
else {
msg_debug_upstream ("cannot mark last alive upstream %s "
- "inactive: %.2f "
+ "inactive; reason: %s; %.2f "
"error rate (%d errors), "
"%.2f max error rate, "
"%.1f first error time, "
"%.1f current ts",
- upstream->name, error_rate, upstream->errors,
- max_error_rate, sec_last, sec_cur);
+ upstream->name,
+ reason,
+ error_rate,
+ upstream->errors,
+ max_error_rate,
+ sec_last,
+ sec_cur);
/* Just re-resolve addresses */
if (sec_cur - sec_last > upstream->ls->limits->revive_time) {
upstream->errors = 0;
@@ -819,7 +836,8 @@ rspamd_upstream_fail (struct upstream *upstream, gboolean addr_failure)
if (addr_failure) {
/* Also increase count of errors for this specific address */
if (upstream->addrs.addr) {
- addr_elt = g_ptr_array_index (upstream->addrs.addr, upstream->addrs.cur);
+ addr_elt = g_ptr_array_index (upstream->addrs.addr,
+ upstream->addrs.cur);
addr_elt->errors++;
}
}