prevent threads not awaiting migration from blocking their response
This commit is contained in:
parent
c49c1a89c9
commit
b8cedada48
|
@ -232,10 +232,12 @@ subscriptionDelivery serv senderID subList = do
|
|||
:: STM (Either String ()))
|
||||
-- TODO: should this always signal migration finished to avoid deadlocksP
|
||||
liftIO $ putMVar syncMVar () -- wakes up waiting thread
|
||||
liftIO $ putMVar syncMVar () -- blocks until waiting thread has resumed
|
||||
-- delete this migration from ongoing ones
|
||||
liftIO . atomically $ modifyTVar' (migrationsInProgress serv) $
|
||||
HMap.delete (fromInteger senderID)
|
||||
-- allow response to be completed independently from waiting thread
|
||||
_ <- liftIO . forkIO $ do
|
||||
putMVar syncMVar () -- blocks until waiting thread has resumed
|
||||
-- delete this migration from ongoing ones
|
||||
liftIO . atomically $ modifyTVar' (migrationsInProgress serv) $
|
||||
HMap.delete (fromInteger senderID)
|
||||
case res of
|
||||
Left err -> throwError err410 {errBody = BSUL.fromString err}
|
||||
Right _ -> pure ""
|
||||
|
|
Loading…
Reference in a new issue