core: update simplexmq (connection-level locks) (#1170)

* core: update simplexmq (connection-level locks)

* update simplexmq

* update simplexmq

* update simplexmq

* only run file tests

* update simplexmq

* enable all tests

* update simplexmq
This commit is contained in:
Evgeny Poberezkin
2022-10-04 17:19:00 +01:00
committed by GitHub
parent f9c691cab1
commit 7a54351f15
4 changed files with 6 additions and 10 deletions
+3 -7
View File
@@ -993,9 +993,7 @@ processChatCommand = \case
QuitChat -> liftIO exitSuccess
ShowVersion -> pure $ CRVersionInfo versionNumber
where
withChatLock action = do
ChatController {chatLock = l, smpAgent = a} <- ask
withAgentLock a . withLock l $ action
withChatLock action = asks chatLock >>= (`withLock` action)
-- below code would make command responses asynchronous where they can be slow
-- in View.hs `r'` should be defined as `id` in this case
-- procCmd :: m ChatResponse -> m ChatResponse
@@ -1377,10 +1375,8 @@ subscribeUserConnections agentBatchSubscribe user = do
void . forkIO $ do
threadDelay 1000000
l <- asks chatLock
a <- asks smpAgent
when (fileStatus == FSConnected) . unlessM (isFileActive fileId sndFiles) $
withAgentLock a . withLock l $
sendFileChunk user ft
when (fileStatus == FSConnected) . unlessM (isFileActive fileId sndFiles) . withLock l $
sendFileChunk user ft
rcvFileSubsToView :: Map ConnId (Either AgentErrorType ()) -> Map ConnId RcvFileTransfer -> m ()
rcvFileSubsToView rs = mapM_ (toView . uncurry CRRcvFileSubError) . filterErrors . resultsFor rs
pendingConnSubsToView :: Map ConnId (Either AgentErrorType ()) -> Map ConnId PendingContactConnection -> m ()