Skip to content

Commit 78704fc

Browse files
committed
don't catch asynchronous exceptions in gracefulClose.
Ensuring that "close" is called quickly when the thread is killed.
1 parent e5bfd88 commit 78704fc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Network/Socket/Shutdown.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE ScopedTypeVariables #-}
23

34
#include "HsNetDef.h"
45

@@ -59,7 +60,8 @@ gracefulClose s tmout0 = sendRecvFIN `E.finally` close s
5960
-- Sending TCP FIN.
6061
ex <- E.try $ shutdown s ShutdownSend
6162
case ex of
62-
Left (E.SomeException _) -> return ()
63+
-- Don't catch asynchronous exceptions
64+
Left (_ :: E.IOException) -> return ()
6365
Right () -> do
6466
-- Giving CPU time to other threads hoping that
6567
-- FIN arrives meanwhile.

0 commit comments

Comments
 (0)