From 80b02b2a1ebd84c853a9479a7a36c923058e7ce8 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Sun, 16 Jun 2013 20:16:19 +0100 Subject: [PATCH] Fix hClose002 with the threaded RTS IO manager If 'close fd' failed, then the MVars in the callbackTables would be left empty, which caused deadlocks when we tried to 'take' them again. Now we use 'finally' to ensure that they are refilled even if 'close' throws an exception. --- GHC/Event/Thread.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/GHC/Event/Thread.hs b/GHC/Event/Thread.hs index cbef3c3c..ca8ed1e8 100644 --- a/GHC/Event/Thread.hs +++ b/GHC/Event/Thread.hs @@ -103,8 +103,7 @@ closeFdWith close fd = do (\mgr table -> M.closeFd_ mgr table fd) mgrs tables - close fd - zipWithM_ finish mgrs tableAndCbApps + close fd `finally` zipWithM_ finish mgrs tableAndCbApps where finish mgr (table', cbApp) = do putMVar (M.callbackTableVar mgr fd) table'