[commit: Cabal] master: Fixed crash on Windows due to file handle leak. (b9c1cc3)

Ian Lynagh igloo at earth.li
Tue Jul 19 15:25:39 CEST 2011


Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/b9c1cc331a0b0fe38552f2a3213d6990e6c84f70

>---------------------------------------------------------------

commit b9c1cc331a0b0fe38552f2a3213d6990e6c84f70
Author: Thomas Tuegel <ttuegel at gmail.com>
Date:   Wed May 18 03:04:22 2011 +0000

    Fixed crash on Windows due to file handle leak.
    Ticket #843. Cabal test crashed when trying to delete a temporary log file
    because 'readFile' reads unnecessarily lazily and was keeping a file handle
    open during attempted deletion. This patch forces the entire file to be read
    so the handle will be closed.

>---------------------------------------------------------------

 cabal/Distribution/Simple/Test.hs |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cabal/Distribution/Simple/Test.hs b/cabal/Distribution/Simple/Test.hs
index 54a44e6..d0e14b4 100644
--- a/cabal/Distribution/Simple/Test.hs
+++ b/cabal/Distribution/Simple/Test.hs
@@ -210,7 +210,7 @@ testController flags pkg_descr lbi suite preTest cmd postTest logNamer = do
 
             -- Generate TestSuiteLog from executable exit code and a machine-
             -- readable test log
-            suiteLog <- readFile tempInput >>= return . postTest exit
+            suiteLog <- fmap (postTest exit $!) $ readFile tempInput
 
             -- Generate final log file name
             let finalLogName = testLogDir </> logNamer suiteLog





More information about the Cvs-libraries mailing list