From febead2e0f930536cee4bd0afd36bfb8f7386416 Mon Sep 17 00:00:00 2001 From: Leonid Stryzhevskyi Date: Thu, 9 Feb 2023 04:22:07 +0200 Subject: [PATCH] network::monitor: Fix ConnectionInactivityChecker. --- .../monitor/ConnectionInactivityChecker.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/oatpp/network/monitor/ConnectionInactivityChecker.cpp b/src/oatpp/network/monitor/ConnectionInactivityChecker.cpp index f5b97334..1dfc5f0b 100644 --- a/src/oatpp/network/monitor/ConnectionInactivityChecker.cpp +++ b/src/oatpp/network/monitor/ConnectionInactivityChecker.cpp @@ -42,8 +42,22 @@ std::shared_ptr ConnectionInactivityChecker::createStatCollector( } bool ConnectionInactivityChecker::check(const ConnectionStats& stats, v_int64 currMicroTime) { - return currMicroTime - stats.timestampLastRead < m_lastReadTimeout.count() && - currMicroTime - stats.timestampLastWrite < m_lastWriteTimeout.count(); + + bool goodRead; + if(stats.timestampLastRead == 0) { + goodRead = currMicroTime - stats.timestampCreated < m_lastReadTimeout.count(); + } else { + goodRead = currMicroTime - stats.timestampLastRead < m_lastReadTimeout.count(); + } + + bool goodWrite; + if(stats.timestampLastWrite == 0) { + goodWrite = currMicroTime - stats.timestampCreated < m_lastWriteTimeout.count(); + } else { + goodWrite = currMicroTime - stats.timestampLastWrite < m_lastWriteTimeout.count(); + } + + return goodRead && goodWrite; } }}}