filelock 0.1.1.5 → 0.1.1.6
raw patch · 4 files changed
+58/−27 lines, 4 filesdep ~asyncdep ~unixnew-uploaderPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: async, unix
API changes (from Hackage documentation)
Files
- CHANGELOG.md +17/−0
- System/FileLock.hs +0/−1
- System/FileLock/Internal/Flock.hsc +18/−10
- filelock.cabal +23/−16
+ CHANGELOG.md view
@@ -0,0 +1,17 @@+Changelog for filelock package++0.1.1.6+-------++_2023-04-06, Andreas Abel_++* Fix problem with locking when used with `unix-2.8`+ (issue [#12](https://github.com/takano-akio/filelock/issues/12)).+* Package moved to [@haskell-pkg-janitors](https://github.com/haskell-pkg-janitors/filelock).++Tested with GHC 8.2 - 9.6.++0.1.1.5+-------++_2020-06-30, Takano Akio_
System/FileLock.hs view
@@ -38,7 +38,6 @@ import qualified Control.Exception as E import Control.Monad import Data.IORef-import Data.Traversable (traverse) import Data.Typeable import Prelude
System/FileLock/Internal/Flock.hsc view
@@ -15,7 +15,14 @@ import Foreign.C.Error import Foreign.C.Types import System.Posix.Files-import System.Posix.IO (openFd, closeFd, defaultFileFlags, OpenMode(..), setFdOption, FdOption(..))+import System.Posix.IO+ ( openFd, closeFd, defaultFileFlags, OpenMode(..)+#if MIN_VERSION_unix(2,8,0)+ , OpenFileFlags(cloexec, creat)+#else+ , setFdOption, FdOption(..)+#endif+ ) import System.Posix.Types import Prelude @@ -43,18 +50,19 @@ open :: FilePath -> IO Fd open path = do #if MIN_VERSION_unix(2,8,0)- fd <- openFd path WriteOnly defaultFileFlags+ fd <- openFd path WriteOnly defaultFileFlags{ cloexec = True, creat = Just stdFileMode }+ -- Field cloexec only available from unix-2.8 #else fd <- openFd path WriteOnly (Just stdFileMode) defaultFileFlags-#endif- -- Ideally, we would open the file descriptor with CLOEXEC enabled, but since- -- unix 2.8 hasn't been released yet and we want backwards compatibility with- -- older releases, we set CLOEXEC after opening the file descriptor. This- -- may seem like a race condition at first. However, since the lock is always- -- taken after CLOEXEC is set, the worst that can happen is that a child- -- process inherits the open FD in an unlocked state. While non-ideal from a- -- performance standpoint, it doesn't introduce any locking bugs. setFdOption fd CloseOnExec True+ -- Ideally, we would open the file descriptor with CLOEXEC enabled, but this+ -- is not available in unix < 2.9.+ -- So we set CLOEXEC after opening the file descriptor. This+ -- may seem like a race condition at first. However, since the lock is always+ -- taken after CLOEXEC is set, the worst that can happen is that a child+ -- process inherits the open FD in an unlocked state. While non-ideal from a+ -- performance standpoint, it doesn't introduce any locking bugs.+#endif return fd flock :: Fd -> Bool -> Bool -> IO Bool
filelock.cabal view
@@ -1,31 +1,38 @@--- Initial filelock.cabal generated by cabal init. For further --- documentation, see http://haskell.org/cabal/users-guide/-+cabal-version: >=1.10 name: filelock-version: 0.1.1.5+version: 0.1.1.6 synopsis: Portable interface to file locking (flock / LockFileEx) description: This package provides an interface to Windows and Unix file locking functionalities.-homepage: http://github.com/takano-akio/filelock+homepage: http://github.com/haskell-pkg-janitors/filelock license: PublicDomain license-file: LICENSE author: Takano Akio-maintainer: tak@anoak.io--- copyright: +maintainer: Andreas Abel category: System build-type: Simple--- extra-source-files: -cabal-version: >=1.10-extra-source-files: tests/lock.log.expected-tested-with: GHC ==8.4.2 || ==8.6.5 || ==8.8.3 +extra-source-files:+ CHANGELOG.md+ tests/lock.log.expected++tested-with:+ GHC == 9.6.1+ GHC == 9.4.4+ GHC == 9.2.7+ GHC == 9.0.2+ GHC == 8.10.7+ GHC == 8.8.4+ GHC == 8.6.5+ GHC == 8.4.4+ GHC == 8.2.2+ library+ hs-source-dirs: . exposed-modules: System.FileLock other-modules: System.FileLock.Internal.Flock System.FileLock.Internal.LockFileEx- -- other-extensions: build-depends: base >=4.9.0.0 && <5- -- hs-source-dirs: default-language: Haskell2010 ghc-options: -Wall@@ -40,7 +47,7 @@ type: exitcode-stdio-1.0 hs-source-dirs: tests main-is: test.hs- build-depends: filelock, process >= 1.2.1.0, async, base+ build-depends: filelock, process >= 1.2.1.0, async >= 2.0.0.0, base ghc-options: -threaded default-language: Haskell2010 @@ -48,7 +55,7 @@ type: exitcode-stdio-1.0 hs-source-dirs: tests main-is: interrupt.hs- build-depends: filelock, process >= 1.2.1.0, async, base+ build-depends: filelock, process >= 1.2.1.0, base ghc-options: -threaded default-language: Haskell2010 if os(windows)@@ -56,4 +63,4 @@ source-repository head type: git- location: https://github.com/takano-akio/filelock.git+ location: https://github.com/haskell-pkg-janitors/filelock.git