Skip to content

Commit 49e9ce1

Browse files
authored
agent: skip subscribing servers without queues (#1678)
1 parent 2ca440d commit 49e9ce1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Simplex/Messaging/Agent.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,10 +1443,10 @@ subscribeAllConnections' c onlyNeeded activeUserId_ = handleErr $ do
14431443
tryAllErrors' $ do
14441444
qs <- withStore' c $ \db -> do
14451445
qs <- getUserServerRcvQueueSubs db userId srv onlyNeeded
1446-
atomically $ modifyTVar' currPending (+ length qs) -- update before leaving transaction
1446+
unless (null qs) $ atomically $ modifyTVar' currPending (+ length qs) -- update before leaving transaction
14471447
pure qs
14481448
let n = length qs
1449-
lift $ subscribe qs `E.finally` atomically (modifyTVar' currPending $ subtract n)
1449+
unless (null qs) $ lift $ subscribe qs `E.finally` atomically (modifyTVar' currPending $ subtract n)
14501450
pure n
14511451
where
14521452
subscribe qs = do

0 commit comments

Comments
 (0)