From 33883f2aa5aa173002fcac3fe7ee0f64a04eeb57 Mon Sep 17 00:00:00 2001 From: shum Date: Thu, 15 Oct 2026 08:21:54 +0000 Subject: [PATCH] smp-server: simplify command slot wait --- src/Simplex/Messaging/Server.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Simplex/Messaging/Server.hs b/src/Simplex/Messaging/Server.hs index ffdfbb039..c26a8b0a6 100644 --- a/src/Simplex/Messaging/Server.hs +++ b/src/Simplex/Messaging/Server.hs @@ -53,7 +53,7 @@ import Control.Monad.Except import Control.Monad.IO.Unlift import Control.Monad.Reader import Control.Monad.Trans.Except -import Control.Monad.STM (check) +import Control.Monad.STM (retry) import Crypto.Random (ChaChaDRG) import Data.Bifunctor (first, second) import qualified Data.Aeson as J @@ -1537,7 +1537,7 @@ client clientTimeout <- asks $ waitTimeout . config waitStarted <- liftIO getSystemTime expired <- liftIO $ registerDelay clientTimeout - taken <- atomically $ (True <$ (takeSlot limit >>= check)) `orElse` (False <$ (readTVar expired >>= check)) + taken <- atomically $ ifM (takeSlot limit) (pure True) (ifM (readTVar expired) (pure False) retry) stats <- asks serverStats liftIO $ updateSlotWaitStats stats waitStarted taken pure taken