From b7ba5bcf14e27c098bbb5b4a876dde500c9afe82 Mon Sep 17 00:00:00 2001 From: Denis Tereshkin Date: Tue, 2 Apr 2024 14:31:11 +0700 Subject: [PATCH] brokerclient: call callback even for non-matching sqnum packets --- src/ATrade/Broker/Client.hs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/ATrade/Broker/Client.hs b/src/ATrade/Broker/Client.hs index 19f9beb..1a9a130 100644 --- a/src/ATrade/Broker/Client.hs +++ b/src/ATrade/Broker/Client.hs @@ -185,15 +185,11 @@ notificationThread clientIdentity callbacks ctx ep idCounter cmdVar killMv secPa [_, payload] -> case decode (BL.fromStrict payload) of Just notification -> do currentSqnum <- readIORef notifSqnumRef - if getNotificationSqnum notification /= currentSqnum - then - if currentSqnum > getNotificationSqnum notification - then log Debug "Broker.Client" $ "Already processed notification: " <> (T.pack . show) (getNotificationSqnum notification) - else log Warning "Broker.Client" $ + when (getNotificationSqnum notification /= currentSqnum) $ do + log Warning "Broker.Client" $ "Notification sqnum mismatch: " <> (T.pack . show) currentSqnum <> " -> " <> (T.pack . show) (getNotificationSqnum notification) - else do - atomicWriteIORef notifSqnumRef (nextSqnum currentSqnum) - forM_ callbacks $ \c -> c notification + atomicWriteIORef notifSqnumRef (nextSqnum currentSqnum) + forM_ callbacks $ \c -> c notification atomicWriteIORef lastKnownNotificationSqnum currentSqnum _ -> return () _ -> return ()