From 0fa40fbfb0d578499679a2a5f21d7d9d2da20ee3 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Tue, 4 Oct 2022 14:36:51 +0100 Subject: [PATCH] fix: connection-level locks (#543) * fix: connection-level locks * add context to store error * convert SERatchetNotFound to CONN NOT_FOUND --- src/Simplex/Messaging/Agent.hs | 2 +- src/Simplex/Messaging/Agent/Client.hs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Simplex/Messaging/Agent.hs b/src/Simplex/Messaging/Agent.hs index cb02facf9..9d523daeb 100644 --- a/src/Simplex/Messaging/Agent.hs +++ b/src/Simplex/Messaging/Agent.hs @@ -726,7 +726,7 @@ runCommandProcessing c@AgentClient {subQ} server = do DEL -> tryCommand $ deleteConnection' c connId >> notify OK _ -> notify $ ERR $ INTERNAL $ "unsupported async command " <> show (aCommandTag cmd) AInternalCommand cmd -> case server of - Just _srv -> case cmd of + Just _srv -> withConnLock c connId $ case cmd of ICAckDel _rId srvMsgId msgId -> tryCommand $ ack _rId srvMsgId >> withStore' c (\db -> deleteMsg db connId msgId) ICAck _rId srvMsgId -> tryCommand $ ack _rId srvMsgId ICAllowSecure _rId senderKey -> tryCommand $ do diff --git a/src/Simplex/Messaging/Agent/Client.hs b/src/Simplex/Messaging/Agent/Client.hs index 12279fa00..ca670d612 100644 --- a/src/Simplex/Messaging/Agent/Client.hs +++ b/src/Simplex/Messaging/Agent/Client.hs @@ -850,6 +850,7 @@ withStore c action = do storeError :: StoreError -> AgentErrorType storeError = \case SEConnNotFound -> CONN NOT_FOUND + SERatchetNotFound -> CONN NOT_FOUND SEConnDuplicate -> CONN DUPLICATE SEBadConnType CRcv -> CONN SIMPLEX SEBadConnType CSnd -> CONN SIMPLEX