fix error handling of sending pending messages; set block size to 8192 (#184)

* fix error handling of sending pending messages

* s/tryAction/tryError/
This commit is contained in:
Evgeny Poberezkin authored and GitHub committed 2021-08-29 13:10:59 +01:00
1 parent 7b5ebf7bd2
commit 96c6339306
2 files changed
+12 -11

No files matched your search

+11 -10
View File
@@ -403,21 +403,22 @@ runSrvMsgDelivery c@AgentClient {subQ} srv = do
forever $ do
PendingMsg {connId, msgId} <- atomically $ readTQueue mq
let mId = unId msgId
r <- withStore $ \st ->
(Right <$> getPendingMsgData st connId msgId)
`E.catch` \(e :: E.SomeException) -> pure $ Left e
case r of
Left e -> notify connId $ MERR mId (INTERNAL $ show e)
withStore (\st -> E.try $ getPendingMsgData st connId msgId) >>= \case
Left (e :: E.SomeException) ->
notify connId $ MERR mId (INTERNAL $ show e)
Right (sq, msgBody) -> do
withRetryInterval ri $ \loop -> do
sendAgentMessage c sq msgBody
`catchError` \case
tryError (sendAgentMessage c sq msgBody) >>= \case
Left e -> case e of
SMP SMP.QUOTA -> loop
e@SMP {} -> notify connId $ MERR mId e
SMP {} -> notify connId $ MERR mId e
CMD {} -> notify connId $ MERR mId e
_ -> loop
notify connId $ SENT mId
withStore $ \st -> updateSndMsgStatus st connId msgId SndMsgSent
Right () -> do
notify connId $ SENT mId
withStore $ \st -> updateSndMsgStatus st connId msgId SndMsgSent
where
tryError action = (Right <$> action) `catchError` (pure . Left)
notify :: ConnId -> ACommand 'Agent -> m ()
notify connId cmd = atomically $ writeTBQueue subQ ("", connId, cmd)
+1 -1
View File
@@ -427,7 +427,7 @@ binaryRsaTransport :: Int
binaryRsaTransport = 0
transportBlockSize :: Int
transportBlockSize = 4096
transportBlockSize = 8192
maxTransportBlockSize :: Int
maxTransportBlockSize = 65536