From 699e2da3161c3cb6073033c10d24dd3c4a2b6a64 Mon Sep 17 00:00:00 2001 From: LyokoJeremie Date: Fri, 1 Sep 2023 23:14:45 +0800 Subject: [PATCH] delayCollect->clean --- src/DelayCollection.h | 20 ++++++++++++++++++++ src/StateMonitorServer.cpp | 3 +++ 2 files changed, 23 insertions(+) diff --git a/src/DelayCollection.h b/src/DelayCollection.h index ac6138d..9e4d1ab 100644 --- a/src/DelayCollection.h +++ b/src/DelayCollection.h @@ -135,6 +135,11 @@ namespace DelayCollection { return di.timeClock < time; }); } + + void clean() { + std::lock_guard lg{mtx}; + q.clear(); + } }; class DelayCollect : public std::enable_shared_from_this { @@ -204,6 +209,21 @@ namespace DelayCollection { historyRelayFirstDelay.removeBefore(time); } + void cleanTcpPing() { + historyTcpPing.clean(); + lastTcpPing = TimeMsInvalid; + } + + void cleanHttpPing() { + historyHttpPing.clean(); + lastHttpPing = TimeMsInvalid; + } + + void cleanFirstDelay() { + historyRelayFirstDelay.clean(); + lastRelayFirstDelay = TimeMsInvalid; + } + public: void pushTcpPing(TimeMs t) { lastTcpPing = t; diff --git a/src/StateMonitorServer.cpp b/src/StateMonitorServer.cpp index 9b508ea..82b0980 100644 --- a/src/StateMonitorServer.cpp +++ b/src/StateMonitorServer.cpp @@ -473,6 +473,9 @@ void HttpConnectSession::path_op(HttpConnectSession::QueryPairsType &queryPairs) a->lastOnlinePing = std::chrono::milliseconds{-1}; a->lastConnectTime = UpstreamTimePoint{}; a->lastConnectPing = std::chrono::milliseconds{-1}; + a->delayCollect->cleanTcpPing(); + a->delayCollect->cleanHttpPing(); + a->delayCollect->cleanFirstDelay(); } // recheck upstreamPool->forceCheckNow();