Skip to content

Commit

Permalink
Use safe calls for FS IO to not block a capability.
Browse files Browse the repository at this point in the history
  • Loading branch information
nh2 committed Feb 20, 2021
1 parent c7fa09d commit e036f49
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/System/Posix/Directory/Traversals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ packDirStream = unsafeCoerce

-- the __hscore_* functions are defined in the unix package. We can import them and let
-- the linker figure it out.
foreign import ccall unsafe "__hscore_readdir"
--
-- In contrast to current `unix` we use `safe` calls for anything that
-- does file system IO, because it can take a substantial amount of time
-- on spinning disks or networked file systems, and `unsafe` calls block
-- a capability.
-- See https://github.com/haskell/unix/issues/34.
foreign import ccall safe "__hscore_readdir"
c_readdir :: Ptr CDir -> Ptr (Ptr CDirent) -> IO CInt

foreign import ccall unsafe "__hscore_free_dirent"
Expand Down

0 comments on commit e036f49

Please sign in to comment.