Skip to content

Commit d632ffd

Browse files
committed
send ups when temp errors are present
1 parent 293c4f1 commit d632ffd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Simplex/Messaging/Agent/Client.hs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

13471350
activeClientSession :: AgentClient -> SMPTransportSession -> SessionId -> STM Bool

0 commit comments

Comments
 (0)