From ed9b18e8a7f79b0deebac1f4addf598781f34b97 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Thu, 12 Sep 2024 11:35:57 +0400 Subject: [PATCH] fix race --- src/Simplex/Messaging/Agent/NtfSubSupervisor.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Simplex/Messaging/Agent/NtfSubSupervisor.hs b/src/Simplex/Messaging/Agent/NtfSubSupervisor.hs index 16e4cb92b..82e667355 100644 --- a/src/Simplex/Messaging/Agent/NtfSubSupervisor.hs +++ b/src/Simplex/Messaging/Agent/NtfSubSupervisor.hs @@ -102,12 +102,13 @@ processNtfSub c (connId, cmd) = do withStore' c $ \db -> supervisorUpdateNtfSub db sub' (NSASMP NSASmpKey) lift . void $ getNtfSMPWorker True c smpServer NSCSmpDelete -> do - withStore' c (`getPrimaryRcvQueue` connId) >>= \case - Right rq@RcvQueue {server = smpServer} -> do - logInfo $ "processNtfSub, NSCSmpDelete - rq = " <> tshow rq - withStore' c $ \db -> supervisorUpdateNtfAction db connId (NSASMP NSASmpDelete) - lift . void $ getNtfSMPWorker True c smpServer - _ -> notifyInternalError c connId "NSCSmpDelete - no rcv queue" + sub_ <- withStore' c $ \db -> do + supervisorUpdateNtfAction db connId (NSASMP NSASmpDelete) + getNtfSubscription db connId + logInfo $ "processNtfSub, NSCSmpDelete - sub_ = " <> tshow sub_ + case sub_ of + (Just (NtfSubscription {smpServer}, _)) -> lift . void $ getNtfSMPWorker True c smpServer + _ -> pure () -- err "NSCSmpDelete - no subscription" NSCNtfWorker ntfServer -> lift . void $ getNtfNTFWorker True c ntfServer NSCNtfSMPWorker smpServer -> lift . void $ getNtfSMPWorker True c smpServer