mirror of https://github.com/voidlizard/hbs2
macos fsync issues
This commit is contained in:
parent
d79c7b89e5
commit
3508ad1258
|
@ -74,6 +74,7 @@ library
|
|||
HBS2.Storage.NCQ3.Internal.Files
|
||||
HBS2.Storage.NCQ3.Internal.Fossil
|
||||
HBS2.Storage.NCQ3.Internal.Flags
|
||||
HBS2.Storage.NCQ3.Internal.Fsync
|
||||
HBS2.Storage.NCQ
|
||||
HBS2.Storage.NCQ.Types
|
||||
-- other-modules:
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
{-# LANGUAGE ForeignFunctionInterface #-}
|
||||
{-# LANGUAGE CApiFFI #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
module HBS2.Storage.NCQ3.Internal.Fsync where
|
||||
|
||||
import Foreign.C.Types
|
||||
import System.Posix.Types
|
||||
import System.Posix.Unistd (fileSynchronise)
|
||||
|
||||
foreign import capi unsafe "unistd.h fsync"
|
||||
c_fsync :: CInt -> IO CInt
|
||||
|
||||
#if defined(darwin_HOST_OS)
|
||||
foreign import capi unsafe "fcntl.h fcntl"
|
||||
c_fcntl :: CInt -> CInt -> CInt -> IO CInt
|
||||
|
||||
foreign import capi unsafe "fcntl.h value F_FULLFSYNC"
|
||||
f_FULLFSYNC :: CInt
|
||||
#endif
|
||||
|
||||
fileSynchronisePortable :: Fd -> IO ()
|
||||
fileSynchronisePortable fd@(Fd fdi) = do
|
||||
#if defined(darwin_HOST_OS)
|
||||
c_fcntl fdi f_FULLFSYNC 0
|
||||
#else
|
||||
fileSynchronise fd
|
||||
#endif
|
||||
{-# INLINE fileSynchronisePortable #-}
|
||||
|
||||
|
|
@ -12,6 +12,7 @@ import HBS2.Storage.NCQ3.Internal.Sweep
|
|||
import HBS2.Storage.NCQ3.Internal.MMapCache
|
||||
import HBS2.Storage.NCQ3.Internal.Fossil
|
||||
import HBS2.Storage.NCQ3.Internal.Flags
|
||||
import HBS2.Storage.NCQ3.Internal.Fsync
|
||||
|
||||
import Control.Concurrent.STM qualified as STM
|
||||
import Control.Monad.Trans.Cont
|
||||
|
@ -31,6 +32,8 @@ import System.Posix.IO.ByteString as Posix
|
|||
import System.Posix.Types as Posix
|
||||
import System.Posix.Unistd
|
||||
|
||||
{- HLINT ignore "Eta reduce" -}
|
||||
|
||||
ncqStorageStop :: forall m . MonadUnliftIO m => NCQStorage -> m ()
|
||||
ncqStorageStop NCQStorage{..} = do
|
||||
atomically $ writeTVar ncqStopReq True
|
||||
|
@ -267,7 +270,7 @@ ncqStorageRun ncq@NCQStorage{..} = withSem ncqRunSem $ flip runContT pure do
|
|||
else do
|
||||
|
||||
ss <- appendTailSection fh
|
||||
liftIO (fileSynchronise fh)
|
||||
liftIO (fileSynchronisePortable fh)
|
||||
|
||||
-- ss <- liftIO (PFS.getFdStatus fh) <&> fromIntegral . PFS.fileSize
|
||||
|
||||
|
|
Loading…
Reference in New Issue