From 09e1b6ec14e8214304d64b9c3b973d570f9b5d0f Mon Sep 17 00:00:00 2001 From: simonmar Date: Fri, 14 Mar 2003 13:08:04 +0000 Subject: [PATCH] [project @ 2003-03-14 13:08:04 by simonmar] Attach the finalizer to the write side of a duplex handle, where it should have been. Otherwise finalization of duplex handles doesn't work properly. MERGE TO STABLE --- GHC/Handle.hs | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/GHC/Handle.hs b/GHC/Handle.hs index 260074d..4381de0 100644 --- a/GHC/Handle.hs +++ b/GHC/Handle.hs @@ -320,23 +320,8 @@ stdHandleFinalizer m = do handleFinalizer :: MVar Handle__ -> IO () handleFinalizer m = do h_ <- takeMVar m - let - -- hClose puts both the fd and the handle's type - -- into a closed state, so it's a bit excessive - -- to test for both here, but caution sometimes - -- pays off.. - alreadyClosed = - case haType h_ of { ClosedHandle{} -> True; _ -> False } - fd = fromIntegral (haFD h_) - - when (not alreadyClosed && fd /= -1) $ do - flushWriteBufferOnly h_ - unlockFile fd -#ifdef mingw32_TARGET_OS - (closeFd (haIsStream h_) fd >> return ()) -#else - (c_close fd >> return ()) -#endif + hClose_help h_ + return () -- --------------------------------------------------------------------------- -- Grimy buffer operations @@ -839,7 +824,7 @@ mkDuplexHandle fd is_stream filepath binary = do } read_side <- newMVar r_handle_ - addMVarFinalizer read_side (handleFinalizer read_side) + addMVarFinalizer write_side (handleFinalizer write_side) return (DuplexHandle read_side write_side) -- 1.7.10.4