mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-09-01 15:58:23 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
689d87b5cf |
@@ -700,7 +700,7 @@ sendBatch c@ProtocolClient {client_ = PClient {rcvConcurrency, sndQ}} b = do
|
|||||||
|
|
||||||
-- | Send Protocol command
|
-- | Send Protocol command
|
||||||
sendProtocolCommand :: forall v err msg. ProtocolEncoding v err (ProtoCommand msg) => ProtocolClient v err msg -> Maybe C.APrivateAuthKey -> EntityId -> ProtoCommand msg -> ExceptT (ProtocolClientError err) IO msg
|
sendProtocolCommand :: forall v err msg. ProtocolEncoding v err (ProtoCommand msg) => ProtocolClient v err msg -> Maybe C.APrivateAuthKey -> EntityId -> ProtoCommand msg -> ExceptT (ProtocolClientError err) IO msg
|
||||||
sendProtocolCommand c@ProtocolClient {client_ = PClient {sndQ}, thParams = THandleParams {batch, blockSize}} pKey entId cmd =
|
sendProtocolCommand c@ProtocolClient {client_ = PClient {tcpTimeout, sndQ}, thParams = THandleParams {batch, blockSize}} pKey entId cmd =
|
||||||
ExceptT $ uncurry sendRecv =<< mkTransmission c (pKey, entId, cmd)
|
ExceptT $ uncurry sendRecv =<< mkTransmission c (pKey, entId, cmd)
|
||||||
where
|
where
|
||||||
-- two separate "atomically" needed to avoid blocking
|
-- two separate "atomically" needed to avoid blocking
|
||||||
@@ -711,9 +711,12 @@ sendProtocolCommand c@ProtocolClient {client_ = PClient {sndQ}, thParams = THand
|
|||||||
| B.length s > blockSize - 2 -> pure . Left $ PCETransportError TELargeMsg
|
| B.length s > blockSize - 2 -> pure . Left $ PCETransportError TELargeMsg
|
||||||
| otherwise -> do
|
| otherwise -> do
|
||||||
active <- newTVarIO True
|
active <- newTVarIO True
|
||||||
atomically (writeTBQueue sndQ (active, s))
|
timeout tcpSendTimeout (atomically $ writeTBQueue sndQ (active, s)) >>= \case
|
||||||
response <$> getResponse c active r
|
Nothing -> pure $ Left PCEResponseTimeout
|
||||||
|
Just () -> response <$> getResponse c active r
|
||||||
where
|
where
|
||||||
|
-- TODO: move to configuration
|
||||||
|
tcpSendTimeout = tcpTimeout * 3 -- conservative timeout, allowing some asymmetry in uplink
|
||||||
s
|
s
|
||||||
| batch = tEncodeBatch1 t
|
| batch = tEncodeBatch1 t
|
||||||
| otherwise = tEncode t
|
| otherwise = tEncode t
|
||||||
|
|||||||
Reference in New Issue
Block a user