lukko-0.1.1.2: File locking

Safe HaskellTrustworthy
LanguageHaskell2010

Lukko.OFD

Contents

Description

Linux open file descriptor locking.

https://www.gnu.org/software/libc/manual/html_node/Open-File-Description-Locks.html

We prefer this over BSD locking (e.g. flock) since the latter appears to break in some NFS configurations. Note that we intentionally do not try to use ordinary POSIX file locking due to its peculiar semantics under multi-threaded environments.

Synopsis

Types

fileLockingSupported :: Bool Source #

A constants specifying whether file locking is supported.

data FileLockingMethod Source #

Potentially availble lock methods.

Constructors

MethodOFD

open file descriptor locking

MethodFLock

BSD flock

MethodWindows

Windows locking

MethodNoOp

No-Op (throws FileLockingNotSupported)

Instances
Bounded FileLockingMethod Source # 
Instance details

Defined in Lukko.Internal.Types

Enum FileLockingMethod Source # 
Instance details

Defined in Lukko.Internal.Types

Eq FileLockingMethod Source # 
Instance details

Defined in Lukko.Internal.Types

Ord FileLockingMethod Source # 
Instance details

Defined in Lukko.Internal.Types

Show FileLockingMethod Source # 
Instance details

Defined in Lukko.Internal.Types

fileLockingMethod :: FileLockingMethod Source #

A constant specifying this method

data LockMode Source #

Indicates a mode in which a file should be locked.

Constructors

SharedLock 
ExclusiveLock 

File descriptors

data FD Source #

Opaque file descriptor

This is a wrapper over CInt

fdOpen :: FilePath -> IO FD Source #

Open file to be used for locking.

open(path, O_RDWR | O_CREAT);

fdClose :: FD -> IO () Source #

Close lock file.

close(fd);

fdLock :: FD -> LockMode -> IO () Source #

Lock using OFD locks.

fdTryLock :: FD -> LockMode -> IO Bool Source #

Try to lock using OFD locks.

fdUnlock :: FD -> IO () Source #

Unlock using OFD locks.

Handles

hLock :: Handle -> LockMode -> IO () Source #

Lock using OFD locks.

hTryLock :: Handle -> LockMode -> IO Bool Source #

Try to lock using OFD locks.

hUnlock :: Handle -> IO () Source #

Unlock using OFD locks.