Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label internal Windows hack thread #1021

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion warp/Network/Wai/Handler/Warp/Windows.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Control.Concurrent
import qualified Control.Exception

import Network.Wai.Handler.Warp.Imports
import GHC.Conc (labelThread)

-- | Allow main socket listening thread to be interrupted on Windows platform
--
Expand All @@ -18,7 +19,8 @@ windowsThreadBlockHack :: IO a -> IO a
windowsThreadBlockHack act = do
var <- newEmptyMVar :: IO (MVar (Either Control.Exception.SomeException a))
-- Catch and rethrow even async exceptions, so don't bother with UnliftIO
void . forkIO $ Control.Exception.try act >>= putMVar var
threadId <- forkIO $ Control.Exception.try act >>= putMVar var
labelThread threadId "Windows Thread Block Hack (warp)"
res <- takeMVar var
case res of
Left e -> Control.Exception.throwIO e
Expand Down
Loading