Enscribe Programmer's Guide

10 File and Record Locking
Enscribe File and Record Locks
Access to shareable Enscribe files among two or more processes is coordinated by file locks and
record locks.
Files can be either audited or nonaudited. An audited file is one that is being accessed under the
control of TMF.
For nonaudited files, locks are granted on a file-open basis; that is, they are requested and granted
in conjunction with individual file numbers associated with separate calls to the FILE_OPEN_ system
procedure. A file or record lock through one file number prevents access to that file or record by
any other file number, even within the same process.
For audited files, locks are granted on a transaction basis; that is, they are requested and granted
in conjunction with individual transaction identifiers (transids) associated with separate
BEGINTRANSACTION-ENDTRANSACTION statement pairs within an application program module.
A file or record lock through one transid prevents access to that file or record through any other
transid, even within the same process.
Multiple processes that are accessing the same disk file should always use either file or record
locking before performing any critical sequence of operations to that file.
Locking Modes
Six locking modes are available; they are summarized in this table:
Table 11 Locking Modes
Any attempt to lock a file, or to read or lock a record that
is already locked through a different file number or transid,
Normal mode
is suspended until the existing lock is released. This is the
default locking mode.
Any attempt to lock a file, or to read or lock a record that
is already locked through a different file number or transid,
Reject mode
is rejected with a file-system error 73 (file/record is locked);
no data is returned.
FILE_READ64_, FILE_READUPDATE64_, READ and
READUPDATE requests ignore existing record and file locks;
Read-through Normal mode
encountering a lock does not delay or prevent reading the
record. FILE_LOCKFILE64_, FILE_LOCKREC64_, LOCKFILE,
LOCKREC, FILE_READLOCK64_,
FILE_READUPDATELOCK64_, READLOCK, and
READUPDATELOCK are treated as in normal mode.
FILE_READ64_, FILE_READUPDATE64_, READ and
READUPDATE requests ignore existing record and file locks;
Read-through/reject mode
encountering a lock does not delay or prevent reading the
record. FILE_LOCKFILE64_, FILE_LOCKREC64_, LOCKFILE,
LOCKREC, FILE_READLOCK64_,
FILE_READUPDATELOCK64_, READLOCK, and
READUPDATELOCK are treated as in reject mode.
FILE_READ64_, FILE_READUPDATE64_, READ and
READUPDATE requests ignore existing record and file locks;
Read-warn/normal mode
although an existing lock will not delay or prevent reading
the record, it causes a CCG completion with a warning
code of 9. FILE_LOCKFILE64_, FILE_LOCKREC64_,
LOCKFILE, LOCKREC, FILE_READLOCK64_,
150 File and Record Locking