Compare commits

..
Author SHA1 Message Date
Evgeny Poberezkin 09348c46f7 sync between tests 2025-05-23 11:30:02 +01:00
Evgeny Poberezkin 5a7e4e0da3 increase test timeout 2025-05-23 11:09:18 +01:00
Evgeny Poberezkin dba10c9b37 retry failed tests with debug logging 2025-05-23 09:06:05 +01:00
Evgeny Poberezkin a83e65891d remove test logs 2025-05-23 07:35:40 +01:00
Evgeny Poberezkin ae4f890e4b enable all tests 2025-05-22 21:48:13 +01:00
Evgeny Poberezkin ac7ad150af debug test 2025-05-22 21:34:37 +01:00
Evgeny Poberezkin 758eefc547 version 2025-05-22 20:01:12 +01:00
Evgeny Poberezkin bace6a99c5 optimze, refactor 2025-05-22 19:54:19 +01:00
Evgeny Poberezkin a010e1e836 version 2025-05-22 18:31:44 +01:00
Evgeny Poberezkin 9c157a943c remove subscribed clients from map 2025-05-22 18:31:13 +01:00
Evgeny Poberezkin 32da2f7482 comment 2025-05-22 16:00:24 +01:00
Evgeny Poberezkin beb204cc2b version 2025-05-22 15:57:58 +01:00
Evgeny Poberezkin 18337be331 correct stats for subscriptions 2025-05-22 15:57:01 +01:00
Evgeny Poberezkin 9861df3e3d version 2025-05-22 13:16:46 +01:00
Evgeny Poberezkin 0c962f2df6 comment 2025-05-22 13:16:23 +01:00
Evgeny Poberezkin 01374d5a66 reduce STM contention 2025-05-22 12:51:50 +01:00
Evgeny Poberezkin 67f5f2ea8f hide clients IntMap 2025-05-22 10:51:40 +01:00
Evgeny Poberezkin 43ef908309 smp server: optimize concurrency and memory usage, refactor 2025-05-22 10:02:08 +01:00
5 changed files with 16 additions and 27 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
cabal-version: 1.12
name: simplexmq
version: 6.4.0.5
version: 6.4.0.4
synopsis: SimpleXMQ message broker
description: This package includes <./docs/Simplex-Messaging-Server.html server>,
<./docs/Simplex-Messaging-Client.html client> and
+5 -5
View File
@@ -371,8 +371,8 @@ createConnection c userId enableNtfs = withAgentEnv c .::. newConn c userId enab
{-# INLINE createConnection #-}
-- | Create or update user's contact connection short link
setContactShortLink :: AgentClient -> ConnId -> ConnInfo -> Maybe CRClientData -> AE (ConnShortLink 'CMContact)
setContactShortLink c = withAgentEnv c .:. setContactShortLink' c
setContactShortLink :: AgentClient -> ConnId -> ConnInfo -> AE (ConnShortLink 'CMContact)
setContactShortLink c = withAgentEnv c .: setContactShortLink' c
{-# INLINE setContactShortLink #-}
deleteContactShortLink :: AgentClient -> ConnId -> AE ()
@@ -832,8 +832,8 @@ newConn c userId enableNtfs cMode userData_ clientData pqInitKeys subMode = do
(connId,) <$> newRcvConnSrv c userId connId enableNtfs cMode userData_ clientData pqInitKeys subMode srv
`catchE` \e -> withStore' c (`deleteConnRecord` connId) >> throwE e
setContactShortLink' :: AgentClient -> ConnId -> ConnInfo -> Maybe CRClientData -> AM (ConnShortLink 'CMContact)
setContactShortLink' c connId userData clientData =
setContactShortLink' :: AgentClient -> ConnId -> ConnInfo -> AM (ConnShortLink 'CMContact)
setContactShortLink' c connId userData =
withConnLock c connId "setContactShortLink" $
withStore c (`getConn` connId) >>= \case
SomeConn _ (ContactConnection _ rq) -> do
@@ -855,7 +855,7 @@ setContactShortLink' c connId userData clientData =
Nothing -> do
sigKeys@(_, privSigKey) <- atomically $ C.generateKeyPair @'C.Ed25519 g
let qUri = SMPQueueUri vr $ SMPQueueAddress server sndId (C.publicKey e2ePrivKey) (Just QMContact)
connReq = CRContactUri $ ConnReqUriData SSSimplex smpAgentVRange [qUri] clientData
connReq = CRContactUri $ ConnReqUriData SSSimplex smpAgentVRange [qUri] Nothing
(linkKey, linkData) = SL.encodeSignLinkData sigKeys smpAgentVRange connReq userData
(linkId, k) = SL.contactShortLinkKdf linkKey
srvData <- liftError id $ SL.encryptLinkData g k linkData
+3 -9
View File
@@ -1246,15 +1246,9 @@ client
KEY sKey -> withQueue $ \q _ -> either err (corrId,entId,) <$> secureQueue_ q sKey
RKEY rKeys -> withQueue $ \q qr -> checkMode QMContact qr $ OK <$$ liftIO (updateKeys (queueStore ms) q rKeys)
LSET lnkId d ->
withQueue $ \q QueueRec {queueMode, senderKey, queueData} ->
liftIO $ either err (corrId,entId,)
-- this check allows adding link data to contact addresses created prior to SKEY,
-- using `queueMode == Just QMContact` would prevent it, they have queueMode `Nothing`.
<$> if queueMode /= Just QMMessaging && isNothing senderKey
then case queueData of
Just (lnkId', _) | lnkId' /= lnkId -> pure $ Left AUTH
_ -> OK <$$ addQueueLinkData (queueStore ms) q lnkId d
else pure $ Left AUTH
withQueue $ \q qr -> checkMode QMContact qr $ liftIO $ case queueData qr of
Just (lnkId', _) | lnkId' /= lnkId -> pure $ Left AUTH
_ -> OK <$$ addQueueLinkData (queueStore ms) q lnkId d
LDEL ->
withQueue $ \q qr -> checkMode QMContact qr $ liftIO $ case queueData qr of
Just _ -> OK <$$ deleteQueueLinkData (queueStore ms) q
-5
View File
@@ -13,7 +13,6 @@ module Simplex.Messaging.TMap
insert,
insertM,
delete,
lookupInsert,
lookupDelete,
adjust,
update,
@@ -73,10 +72,6 @@ delete :: Ord k => k -> TMap k a -> STM ()
delete k m = modifyTVar' m $ M.delete k
{-# INLINE delete #-}
lookupInsert :: Ord k => k -> a -> TMap k a -> STM (Maybe a)
lookupInsert k v m = stateTVar m $ M.alterF (,Just v) k
{-# INLINE lookupInsert #-}
lookupDelete :: Ord k => k -> TMap k a -> STM (Maybe a)
lookupDelete k m = stateTVar m $ M.alterF (,Nothing) k
{-# INLINE lookupDelete #-}
+7 -7
View File
@@ -1200,13 +1200,13 @@ testContactShortLink viaProxy a b =
exchangeGreetingsViaProxy viaProxy a bId b aId
-- update user data
let updatedData = "updated user data"
shortLink' <- runRight $ setContactShortLink a contactId updatedData Nothing
shortLink' <- runRight $ setContactShortLink a contactId updatedData
shortLink' `shouldBe` shortLink
(connReq4, updatedConnData') <- runRight $ getConnShortLink c 1 shortLink
connReq4 `shouldBe` connReq
linkUserData updatedConnData' `shouldBe` updatedData
-- one more time
shortLink2 <- runRight $ setContactShortLink a contactId updatedData Nothing
shortLink2 <- runRight $ setContactShortLink a contactId updatedData
shortLink2 `shouldBe` shortLink
-- delete short link
runRight_ $ deleteContactShortLink a contactId
@@ -1219,7 +1219,7 @@ testAddContactShortLink viaProxy a b =
(contactId, CCLink connReq0 Nothing) <- runRight $ A.createConnection a 1 True SCMContact Nothing Nothing CR.IKPQOn SMSubscribe
Right connReq <- pure $ smpDecode (smpEncode connReq0) --
let userData = "some user data"
shortLink <- runRight $ setContactShortLink a contactId userData Nothing
shortLink <- runRight $ setContactShortLink a contactId userData
(connReq', connData') <- runRight $ getConnShortLink b 1 shortLink
strDecode (strEncode shortLink) `shouldBe` Right shortLink
connReq' `shouldBe` connReq
@@ -1247,7 +1247,7 @@ testAddContactShortLink viaProxy a b =
exchangeGreetingsViaProxy viaProxy a bId b aId
-- update user data
let updatedData = "updated user data"
shortLink' <- runRight $ setContactShortLink a contactId updatedData Nothing
shortLink' <- runRight $ setContactShortLink a contactId updatedData
shortLink' `shouldBe` shortLink
(connReq4, updatedConnData') <- runRight $ getConnShortLink c 1 shortLink
connReq4 `shouldBe` connReq
@@ -1278,7 +1278,7 @@ testContactShortLinkRestart ps = withAgentClients2 $ \a b -> do
connReq' `shouldBe` connReq
linkUserData connData' `shouldBe` userData
-- update user data
shortLink' <- runRight $ setContactShortLink a contactId updatedData Nothing
shortLink' <- runRight $ setContactShortLink a contactId updatedData
shortLink' `shouldBe` shortLink
withSmpServer ps $ do
(connReq4, updatedConnData') <- runRight $ getConnShortLink b 1 shortLink
@@ -1290,7 +1290,7 @@ testAddContactShortLinkRestart ps = withAgentClients2 $ \a b -> do
let userData = "some user data"
((contactId, CCLink connReq0 Nothing), shortLink) <- withSmpServer ps $ runRight $ do
r@(contactId, _) <- A.createConnection a 1 True SCMContact Nothing Nothing CR.IKPQOn SMOnlyCreate
(r,) <$> setContactShortLink a contactId userData Nothing
(r,) <$> setContactShortLink a contactId userData
Right connReq <- pure $ smpDecode (smpEncode connReq0)
let updatedData = "updated user data"
withSmpServer ps $ do
@@ -1299,7 +1299,7 @@ testAddContactShortLinkRestart ps = withAgentClients2 $ \a b -> do
connReq' `shouldBe` connReq
linkUserData connData' `shouldBe` userData
-- update user data
shortLink' <- runRight $ setContactShortLink a contactId updatedData Nothing
shortLink' <- runRight $ setContactShortLink a contactId updatedData
shortLink' `shouldBe` shortLink
withSmpServer ps $ do
(connReq4, updatedConnData') <- runRight $ getConnShortLink b 1 shortLink