[commit: base] master: Release the FD lock before calling close() (#7646) (fbd4b4c)
Simon Marlow
marlowsd at gmail.com
Mon Feb 4 13:24:48 CET 2013
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/fbd4b4c2587636811d464040e349d81fac9e1121
>---------------------------------------------------------------
commit fbd4b4c2587636811d464040e349d81fac9e1121
Author: Simon Marlow <marlowsd at gmail.com>
Date: Mon Feb 4 12:08:00 2013 +0000
Release the FD lock before calling close() (#7646)
>---------------------------------------------------------------
GHC/IO/FD.hs | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/GHC/IO/FD.hs b/GHC/IO/FD.hs
index 0f37a81..fdeeb74 100644
--- a/GHC/IO/FD.hs
+++ b/GHC/IO/FD.hs
@@ -315,7 +315,6 @@ stderr = stdFD 2
close :: FD -> IO ()
close fd =
- (flip finally) (release fd) $
do let closer realFd =
throwErrnoIfMinus1Retry_ "GHC.IO.FD.close" $
#ifdef mingw32_HOST_OS
@@ -324,6 +323,12 @@ close fd =
else
#endif
c_close (fromIntegral realFd)
+
+ -- release the lock *first*, because otherwise if we're preempted
+ -- after closing but before releasing, the FD may have been reused.
+ -- (#7646)
+ release fd
+
closeFdWith closer (fromIntegral (fdFD fd))
release :: FD -> IO ()
More information about the ghc-commits
mailing list