[commit: packages/directory] master: Make foreign imports of realpath and utimensat safe (27bfd06)

git at git.haskell.org git at git.haskell.org
Fri Dec 18 09:52:34 UTC 2015


Repository : ssh://git@git.haskell.org/directory

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/27bfd06ac3a8805976820677c508bf986f7c8cc3/directory

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

commit 27bfd06ac3a8805976820677c508bf986f7c8cc3
Author: Phil Ruffwind <rf at rufflewind.com>
Date:   Sat Sep 5 04:07:20 2015 -0400

    Make foreign imports of realpath and utimensat safe
    
    Although these functions never return EINTR, signals may still affect
    these calls.  In particular, realpath on Mac OS X contains a
    retry-if-interrupted loop on statfs64.  If the file system is slow
    (e.g. SSHFS), the call will hang due to the barrage of periodic alarm
    signals from the GHC runtime.  Marking the foreign import as safe
    appears to silence the alarm signals, although it is not guaranteed [1].
    This is the best we can do until [2] gets fixed.
    
    We also do this for utimensat as a precautionary measure.  Given that
    these are system calls that manipulate the file system, the performance
    overhead ought to be negligible.
    
    This should alleviate #35 for now.
    
    [1] https://mail.haskell.org/pipermail/ghc-devs/2015-September/009770.html
    [2] https://ghc.haskell.org/trac/ghc/ticket/10840


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

27bfd06ac3a8805976820677c508bf986f7c8cc3
 System/Directory/Internal/C_utimensat.hsc | 2 +-
 System/Directory/Internal/Posix.hsc       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/System/Directory/Internal/C_utimensat.hsc b/System/Directory/Internal/C_utimensat.hsc
index 7497f7e..d1775fb 100644
--- a/System/Directory/Internal/C_utimensat.hsc
+++ b/System/Directory/Internal/C_utimensat.hsc
@@ -42,7 +42,7 @@ toCTimeSpec t = CTimeSpec (CTime sec) (truncate $ 10 ^ (9 :: Int) * frac)
     (sec,  frac)  = if frac' < 0 then (sec' - 1, frac' + 1) else (sec', frac')
     (sec', frac') = properFraction (toRational t)
 
-foreign import ccall unsafe "utimensat" c_utimensat
+foreign import ccall "utimensat" c_utimensat
   :: CInt -> CString -> Ptr CTimeSpec -> CInt -> IO CInt
 
 #endif
diff --git a/System/Directory/Internal/Posix.hsc b/System/Directory/Internal/Posix.hsc
index 231e822..8dfd6fb 100644
--- a/System/Directory/Internal/Posix.hsc
+++ b/System/Directory/Internal/Posix.hsc
@@ -25,7 +25,7 @@ c_PATH_MAX | c_PATH_MAX' > toInteger maxValue = Nothing
 c_PATH_MAX = Nothing
 #endif
 
-foreign import ccall unsafe "realpath" c_realpath
+foreign import ccall "realpath" c_realpath
   :: CString -> CString -> IO CString
 
 withRealpath :: CString -> (CString -> IO a) -> IO a



More information about the ghc-commits mailing list