From 2f7d07a872a9d387c79e6a1eafd7b60da5329d42 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Wed, 21 Aug 2024 13:42:23 +0100 Subject: [PATCH] smp server: expire subscribed clients too, with 3x TTL --- src/Simplex/Messaging/Server.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Simplex/Messaging/Server.hs b/src/Simplex/Messaging/Server.hs index a70995d5e..76f597920 100644 --- a/src/Simplex/Messaging/Server.hs +++ b/src/Simplex/Messaging/Server.hs @@ -744,11 +744,14 @@ disconnectTransport THandle {connection, params = THandleParams {sessionId}} rcv where loop = do threadDelay' $ checkInterval expCfg * 1000000 - ifM noSubscriptions checkExpired loop - checkExpired = do - old <- expireBeforeEpoch expCfg + ifM noSubscriptions (checkExpired expCfg) (checkExpired expCfg') + checkExpired cfg = do + old <- expireBeforeEpoch cfg ts <- max <$> readTVarIO rcvActiveAt <*> readTVarIO sndActiveAt if systemSeconds ts < old then closeConnection connection else loop + expCfg' = + let ExpirationConfig {ttl} = expCfg + in expCfg {ttl = 3 * ttl} data VerificationResult = VRVerified (Maybe QueueRec) | VRFailed