network::monitor: Fix ConnectionInactivityChecker.

This commit is contained in:
Leonid Stryzhevskyi 2023-02-09 04:22:07 +02:00
parent cc1888b3e0
commit febead2e0f

View File

@ -42,8 +42,22 @@ std::shared_ptr<StatCollector> 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;
}
}}}