[commit: base] : closeFdWith closes fd after unregistering the fd with the backend. (6e27730)
Johan Tibell
johan.tibell at gmail.com
Tue Feb 12 07:51:26 CET 2013
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch :
http://hackage.haskell.org/trac/ghc/changeset/6e277300023e3d0bb4112f102eb91dff47be861c
>---------------------------------------------------------------
commit 6e277300023e3d0bb4112f102eb91dff47be861c
Author: Andreas Voellmy <andreas.voellmy at gmail.com>
Date: Fri Jan 4 09:54:50 2013 -0500
closeFdWith closes fd after unregistering the fd with the backend.
In closeFdWith moved closing of fd after calling closeFd_ on each capabilities manager, ensuring that the fd is still valid when the fd is deregistered with the backend.
>---------------------------------------------------------------
GHC/Event/Thread.hs | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/GHC/Event/Thread.hs b/GHC/Event/Thread.hs
index 99c3280..915b5f3 100644
--- a/GHC/Event/Thread.hs
+++ b/GHC/Event/Thread.hs
@@ -15,7 +15,7 @@ module GHC.Event.Thread
) where
import Control.Exception (finally)
-import Control.Monad (forM, forM_, zipWithM_, when)
+import Control.Monad (forM, forM_, zipWithM, zipWithM_, when)
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
import Data.Maybe (Maybe(..))
import Data.Tuple (snd)
@@ -100,11 +100,15 @@ closeFdWith close fd = do
return (mgr, M.callbackTableVar mgr fd)
mask_ $ do
tables <- forM tableVars (takeMVar.snd)
+ tables' <- zipWithM
+ (\(mgr,tableVar) table -> M.closeFd_ mgr table fd)
+ tableVars
+ tables
close fd
zipWithM_
- (\(mgr,tableVar) table -> M.closeFd_ mgr table fd >>= putMVar tableVar)
+ (\(mgr,tableVar) table' -> putMVar tableVar table')
tableVars
- tables
+ tables'
threadWait :: Event -> Fd -> IO ()
threadWait evt fd = mask_ $ do
More information about the ghc-commits
mailing list