From 3806a478156ff0e8bf36068a6819092773c5773b Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Mon, 3 Feb 2020 13:57:02 +0100 Subject: [PATCH] connect & accept: change the scope of masked exceptions Limit the scope of masked exceptions only to the 'Network.Socket.connect' / 'Network.Socket.accept' call. --- Win32-network/src/System/Win32/Async/Socket.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Win32-network/src/System/Win32/Async/Socket.hs b/Win32-network/src/System/Win32/Async/Socket.hs index 22f03b3270b..407536e3259 100644 --- a/Win32-network/src/System/Win32/Async/Socket.hs +++ b/Win32-network/src/System/Win32/Async/Socket.hs @@ -54,7 +54,7 @@ connect :: Socket -> SockAddr -> IO () connect sock addr = do v <- newEmptyMVar _ <- mask_ $ forkIOWithUnmask $ \unmask -> - unmask (Socket.connect sock addr >> putMVar v Nothing) + (unmask (Socket.connect sock addr) >> putMVar v Nothing) `catch` (\(e :: IOException) -> putMVar v (Just e)) r <- takeMVar v case r of @@ -76,7 +76,7 @@ accept :: Socket -> IO (Socket, SockAddr) accept sock = do v <- newEmptyMVar _ <- mask_ $ forkIOWithUnmask $ \unmask -> - unmask (Socket.accept sock >>= putMVar v . Right) + (unmask (Socket.accept sock) >>= putMVar v . Right) `catch` (\(e :: IOException) -> putMVar v (Left e)) r <- takeMVar v case r of