Browse Source

brokerclient: call callback even for non-matching sqnum packets

master
Denis Tereshkin 2 years ago
parent
commit
b7ba5bcf14
  1. 12
      src/ATrade/Broker/Client.hs

12
src/ATrade/Broker/Client.hs

@ -185,15 +185,11 @@ notificationThread clientIdentity callbacks ctx ep idCounter cmdVar killMv secPa @@ -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 ()

Loading…
Cancel
Save