fix hang when built with unix-2.8
git-annex test hang when running git-annex add in an adjusted unlocked
branch. I couldn't seem to reproduce the hang outside the test suite.
Seems that the code added in 26a9ea12d1
was buggy, and as that commit was made without testing it, building with
unix-2.8 exposed the bug.
I don't fully understand the bug, which involves fdToHandle
and then closing the fd, vs closing the handle. May somehow involve
laziness or forcing around the S.hGet? Using hClose solved it
in any case.
(Also eliminated checkcontentfollowssymlinks to fix a build warning
when it's not used.)
This commit is contained in:
parent
6da6449fff
commit
3a52b4c4c3
1 changed files with 7 additions and 8 deletions
|
@ -434,23 +434,22 @@ maxSymlinkSz = 8192
|
|||
isPointerFile :: RawFilePath -> IO (Maybe Key)
|
||||
isPointerFile f = catchDefaultIO Nothing $
|
||||
#if defined(mingw32_HOST_OS)
|
||||
checkcontentfollowssymlinks -- no symlinks supported on windows
|
||||
withFile (fromRawFilePath f) ReadMode readhandle
|
||||
#else
|
||||
#if MIN_VERSION_unix(2,8,0)
|
||||
bracket
|
||||
(openFd (fromRawFilePath f) ReadOnly (defaultFileFlags { nofollow = True }))
|
||||
closeFd
|
||||
(\fd -> readhandle =<< fdToHandle fd)
|
||||
let open = do
|
||||
fd <- openFd (fromRawFilePath f) ReadOnly
|
||||
(defaultFileFlags { nofollow = True })
|
||||
fdToHandle fd
|
||||
in bracket open hClose readhandle
|
||||
#else
|
||||
ifM (isSymbolicLink <$> R.getSymbolicLinkStatus f)
|
||||
( return Nothing
|
||||
, checkcontentfollowssymlinks
|
||||
, withFile (fromRawFilePath f) ReadMode readhandle
|
||||
)
|
||||
#endif
|
||||
#endif
|
||||
where
|
||||
checkcontentfollowssymlinks =
|
||||
withFile (fromRawFilePath f) ReadMode readhandle
|
||||
readhandle h = parseLinkTargetOrPointer <$> S.hGet h maxPointerSz
|
||||
|
||||
{- Checks a symlink target or pointer file first line to see if it
|
||||
|
|
Loading…
Reference in a new issue