prevent threads not awaiting migration from blocking their response

This commit is contained in:
Trolli Schmittlauch 2020-08-17 11:37:04 +02:00
parent c49c1a89c9
commit b8cedada48

View file

@ -232,10 +232,12 @@ subscriptionDelivery serv senderID subList = do
:: STM (Either String ())) :: STM (Either String ()))
-- TODO: should this always signal migration finished to avoid deadlocksP -- TODO: should this always signal migration finished to avoid deadlocksP
liftIO $ putMVar syncMVar () -- wakes up waiting thread liftIO $ putMVar syncMVar () -- wakes up waiting thread
liftIO $ putMVar syncMVar () -- blocks until waiting thread has resumed -- allow response to be completed independently from waiting thread
-- delete this migration from ongoing ones _ <- liftIO . forkIO $ do
liftIO . atomically $ modifyTVar' (migrationsInProgress serv) $ putMVar syncMVar () -- blocks until waiting thread has resumed
HMap.delete (fromInteger senderID) -- delete this migration from ongoing ones
liftIO . atomically $ modifyTVar' (migrationsInProgress serv) $
HMap.delete (fromInteger senderID)
case res of case res of
Left err -> throwError err410 {errBody = BSUL.fromString err} Left err -> throwError err410 {errBody = BSUL.fromString err}
Right _ -> pure "" Right _ -> pure ""