From 751ea5edd7247373da2fdb3b0047f1d558ace753 Mon Sep 17 00:00:00 2001 From: Justin Azoff Date: Fri, 1 May 2020 09:36:50 -0400 Subject: [PATCH] avoid scheduling redundant inactivity timers When setting the inactivity timeout, don't schedule a new timer if the new one would be redundant. --- src/Conn.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Conn.cc b/src/Conn.cc index 26fd5a191c..55c123e066 100644 --- a/src/Conn.cc +++ b/src/Conn.cc @@ -308,9 +308,10 @@ void Connection::RemoveConnectionTimer(double t) void Connection::SetInactivityTimeout(double timeout) { - // We add a new inactivity timer even if there already is one. When - // it fires, we always use the current value to check for inactivity. - if ( timeout ) + // We add a new inactivity timer if there is no current timeout or if the + // new timeout is lower than the old one. When it fires, we always use the + // current value to check for inactivity and re-schedule the next timer. + if ( timeout && (inactivity_timeout == 0 || timeout < inactivity_timeout) ) ADD_TIMER(&Connection::InactivityTimer, last_time + timeout, 0, TIMER_CONN_INACTIVITY);