Browse Source

brokerclient: call callback even for non-matching sqnum packets

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

8
src/ATrade/Broker/Client.hs

@ -185,13 +185,9 @@ notificationThread clientIdentity callbacks ctx ep idCounter cmdVar killMv secPa
[_, payload] -> case decode (BL.fromStrict payload) of [_, payload] -> case decode (BL.fromStrict payload) of
Just notification -> do Just notification -> do
currentSqnum <- readIORef notifSqnumRef currentSqnum <- readIORef notifSqnumRef
if getNotificationSqnum notification /= currentSqnum when (getNotificationSqnum notification /= currentSqnum) $ do
then log Warning "Broker.Client" $
if currentSqnum > getNotificationSqnum notification
then log Debug "Broker.Client" $ "Already processed notification: " <> (T.pack . show) (getNotificationSqnum notification)
else log Warning "Broker.Client" $
"Notification sqnum mismatch: " <> (T.pack . show) currentSqnum <> " -> " <> (T.pack . show) (getNotificationSqnum notification) "Notification sqnum mismatch: " <> (T.pack . show) currentSqnum <> " -> " <> (T.pack . show) (getNotificationSqnum notification)
else do
atomicWriteIORef notifSqnumRef (nextSqnum currentSqnum) atomicWriteIORef notifSqnumRef (nextSqnum currentSqnum)
forM_ callbacks $ \c -> c notification forM_ callbacks $ \c -> c notification
atomicWriteIORef lastKnownNotificationSqnum currentSqnum atomicWriteIORef lastKnownNotificationSqnum currentSqnum

Loading…
Cancel
Save