From ef5ecf4d7805be1e17b133e05132b4942ed5d9eb Mon Sep 17 00:00:00 2001 From: John Rushford Date: Thu, 28 Apr 2022 18:44:08 +0000 Subject: [PATCH] Fixes issue #8807 nexthop failure threshold. This was originally fixed in ATS 9.2.x with PR #8365 but #8365 was big and not backported to 9.1.x as it was a late PR and zwoop did not want to bring it into 9.1.x at that time. Anyway, this fixes the issue where the failure count on a parent is not incremented properly. --- proxy/http/remap/NextHopHealthStatus.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/proxy/http/remap/NextHopHealthStatus.cc b/proxy/http/remap/NextHopHealthStatus.cc index afb43c7222c..2412171b52d 100644 --- a/proxy/http/remap/NextHopHealthStatus.cc +++ b/proxy/http/remap/NextHopHealthStatus.cc @@ -119,22 +119,21 @@ NextHopHealthStatus::markNextHop(TSHttpTxn txn, const char *hostname, const int new_fail_count = h->failCount = 1; } } else if (result.retry == true) { - h->failedAt = _now; + h->failedAt = _now; + new_fail_count = h->failCount = 1; } } // end lock guard NH_Note("[%" PRId64 "] NextHop %s marked as down %s", sm_id, (result.retry) ? "retry" : "initially", h->hostname.c_str()); } else { - int old_count = 0; // if the last failure was outside the retry window, set the failcount to 1 and failedAt to now. { // lock guard std::lock_guard lock(h->_mutex); if ((h->failedAt + retry_time) < static_cast(_now)) { - h->failCount = 1; - h->failedAt = _now; + new_fail_count = h->failCount = 1; + h->failedAt = _now; } else { - old_count = h->failCount = 1; + new_fail_count = h->failCount += 1; } - new_fail_count = old_count + 1; } // end of lock_guard NH_Debug(NH_DEBUG_TAG, "[%" PRId64 "] Parent fail count increased to %d for %s", sm_id, new_fail_count, h->hostname.c_str()); }