async exception safety for openFd
Audited for openFile and openFd, and this fixes all the ones I found where an async exception could prevent the file getting closed. Except for the lock pool, which is a whole other can of worms.
This commit is contained in:
parent
1dd770b1af
commit
0210e81d83
5 changed files with 35 additions and 13 deletions
|
@ -174,12 +174,13 @@ linkToLock (Just _) src dest = do
|
|||
, return False
|
||||
)
|
||||
Left _ -> catchBoolIO $ do
|
||||
fd <- openFd dest WriteOnly
|
||||
(Just $ combineModes readModes)
|
||||
(defaultFileFlags {exclusive = True})
|
||||
h <- fdToHandle fd
|
||||
readFile src >>= hPutStr h
|
||||
hClose h
|
||||
let setup = do
|
||||
fd <- openFd dest WriteOnly
|
||||
(Just $ combineModes readModes)
|
||||
(defaultFileFlags {exclusive = True})
|
||||
fdToHandle fd
|
||||
let cleanup = hClose
|
||||
bracket setup cleanup (\h -> readFile src >>= hPutStr h)
|
||||
return True
|
||||
where
|
||||
checklinked = do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue