Fix System.Timeout.timeout leaking Timeout exceptions (#7719).
authorBertram Felgenhauer <int-e@gmx.de>
Thu, 7 Mar 2013 01:18:17 +0000 (02:18 +0100)
committerIan Lynagh <ian@well-typed.com>
Sun, 21 Apr 2013 12:38:07 +0000 (13:38 +0100)
System/Timeout.hs

index e0b20ea..be44ba3 100644 (file)
@@ -27,6 +27,7 @@ module System.Timeout ( timeout ) where
 #ifdef __GLASGOW_HASKELL__
 import Control.Concurrent
 import Control.Exception   (Exception(..), handleJust, bracket,
+                            uninterruptibleMask_,
                             asyncExceptionToException,
                             asyncExceptionFromException)
 import Data.Typeable
@@ -90,8 +91,9 @@ timeout n f
                    (\_ -> return Nothing)
                    (bracket (forkIOWithUnmask $ \unmask ->
                                  unmask $ threadDelay n >> throwTo pid ex)
-                            (killThread)
+                            (uninterruptibleMask_ . killThread)
                             (\_ -> fmap Just f))
+        -- #7719 explains why we need uninterruptibleMask_ above.
 #else
 timeout n f = fmap Just f
 #endif /* !__GLASGOW_HASKELL__ */