Locks a byte range for the specified open file object.
#include <zPublics.h> STATUS zLockByteRange( Key_t key, Xid_t xid, NINT mode, QUAD startingOffset, QUAD length, NINT msecTimeout);
(IN) Specifies the file (as returned by zOpen or zCreate) whose byte range is being locked.
(IN) Specifies the transaction to which the lock is bound. If the requested action is not part of a transaction, pass zNILXID; the lock is then bound to the task specified by the key.
(IN) Specifies the mode of the lock: either zLOCK_SHARED (read lock) or zLOCK_EXCLUSIVE (write lock).
(IN) Specifies the logical byte offset in the file where the lock begins.
(IN) Specifies the number of bytes to lock in the file. To lock all the bytes in a file, set startingOffset to 0 and length to zMAX_FILE_SIZE (0xffffffffffffffff: a 64 bit -1).
(IN) Specifies the number of milliseconds that you are willing to wait to receive the lock. Otherwise, it immediately returns an error if the lock cannot be obtained.
zOK |
The operation completed successfully. |
zERR_LOCK_WAITING |
Did not get the lock in the specified amount of time. |
non-0 |
An error occurred (see Section 4.1, Return Values for a description). |
zLockByteRange locks the number of bytes specified by length, starting at the startingOffset of the file identified by key. A lock bound to a transaction can only be unlocked by either ending or aborting the transaction. When the transaction holding the lock ends on a nested transaction, its parent inherits all the locks of the child. To prevent dirty reads of data and preserve reread semantics, locks are finally released when the root transaction commits.