@@ -1325,23 +1325,26 @@ subscribeQueues c qs = do
13251325 subscribeQueues_ :: Env -> TVar (Maybe SessionId ) -> SMPClient -> NonEmpty RcvQueue -> IO (BatchResponses SMPClientError () )
13261326 subscribeQueues_ env session smp qs' = do
13271327 rs <- sendBatch subscribeSMPQueues smp qs'
1328- (active, up ) <-
1328+ (active, subResults ) <-
13291329 atomically $
13301330 ifM
13311331 (activeClientSession c tSess sessId)
13321332 (writeTVar session (Just sessId) >> ((True ,) <$> processSubResults rs))
13331333 (pure (False , [] ))
13341334 if active
1335- then rs <$ if hasTempErrors rs then resubscribe else unless (null up) (notifySub c " " $ UP srv up)
1335+ then do
1336+ when (any isNothing subResults) resubscribe
1337+ let up = catMaybes $ L. toList subResults
1338+ unless (null up) $ notifySub c " " $ UP srv up
1339+ pure rs
13361340 else do
13371341 logWarn " subcription batch result for replaced SMP client, resubscribing"
13381342 resubscribe $> L. map (second $ \ _ -> Left PCENetworkError ) rs
13391343 where
13401344 tSess@ (_, srv, _) = transportSession' smp
13411345 sessId = sessionId $ thParams smp
1342- hasTempErrors = any (either temporaryClientError (const False ) . snd )
1343- processSubResults :: NonEmpty (RcvQueue , Either SMPClientError () ) -> STM [ConnId ]
1344- processSubResults = fmap catMaybes . mapM (uncurry $ processSubResult c) . L. toList
1346+ processSubResults :: NonEmpty (RcvQueue , Either SMPClientError () ) -> STM (NonEmpty (Maybe ConnId ))
1347+ processSubResults = mapM (uncurry $ processSubResult c)
13451348 resubscribe = resubscribeSMPSession c tSess `runReaderT` env
13461349
13471350activeClientSession :: AgentClient -> SMPTransportSession -> SessionId -> STM Bool
0 commit comments