This commit is contained in:
Evgeny Poberezkin
2025-06-08 22:34:26 +01:00
parent 3948980000
commit d3f229a666
2 changed files with 10 additions and 12 deletions
+8 -9
View File
@@ -1108,15 +1108,14 @@ receive h@THandle {params = THandleParams {thAuth, sessionId}} ms Client {rcvQ,
verified :: ServerStats -> SignedTransmission Cmd -> VerificationResult s -> IO (VerifiedTransmissionOrError s)
verified stats (_, _, t@(corrId, entId, Cmd _ command)) = \case
VRVerified q -> pure $ Right (q, t)
VRFailed AUTH -> do
case command of
SEND {} -> incStat $ msgSentAuth stats
SUB -> incStat $ qSubAuth stats
NSUB -> incStat $ ntfSubAuth stats
GET -> incStat $ msgGetAuth stats
_ -> pure ()
pure $ Left (corrId, entId, ERR AUTH)
VRFailed e -> pure $ Left (corrId, entId, ERR e)
VRFailed e -> Left (corrId, entId, ERR e) <$ when (e == AUTH) incAuthStat
where
incAuthStat = case command of
SEND {} -> incStat $ msgSentAuth stats
SUB -> incStat $ qSubAuth stats
NSUB -> incStat $ ntfSubAuth stats
GET -> incStat $ msgGetAuth stats
_ -> pure ()
write q = mapM_ (atomically . writeTBQueue q) . L.nonEmpty
send :: Transport c => MVar (THandleSMP c 'TServer) -> Client s -> IO ()
@@ -258,9 +258,8 @@ instance StoreQueueClass q => QueueStoreClass q (PostgresQueueStore q) where
pure $ map (result qs_) qs'
where
result :: Either ErrorType (M.Map QueueId q) -> Either QueueId q -> Either ErrorType q
result qs_ = \case
Right q -> Right q
Left qId -> maybe (Left AUTH) Right . M.lookup qId =<< qs_
result _ (Right q) = Right q
result qs_ (Left qId) = maybe (Left AUTH) Right . M.lookup qId =<< qs_
cacheRcvQueue (rId, qRec) = do
sq <- mkQ True rId qRec
sq' <- withQueueLock sq "getQueue_" $ atomically $