TBLT_RETC TBLT_ENTRY BltLockIx4File(TBLT_KH *khPtr, ULONG mode, ULONG timeout); khPtr I:index file control structure mode I:lock type timeout I:timeout, in millisecondsThis routine locks the index file.
The mode can be a combination of the following:
LOCK_MODE_EXCLUSIVE or LOCK_MODE_SHARED LOCK_MODE_SH2EX or LOCK_MODE_EX2SH LOCK_MODE_ATOMICAtomic locks are only available on 32-bit OS/2. Shared locks (and the
SH2EX
and EX2SH
) are only available on 32-bit
OS/2 and WinNT. A shared lock is a read-only lock, where any process may
read the file, but no process may write to it.
If the lock cannot be made before the timeout period ends the error
EXB_TIMEOUT
is returned.
At index file open, the open mode could have the flag,
FLAGS_READ_THROUGH_LOCK_BITspecified. This is similar to a shared lock, in that any process may read the locked region by simply not attempting to lock the region before reading it. However, there is no write protection unless the programmer attempts to lock the locked region before writing to it. The optional lockix4.c and lockdata.c files cover this technique. If you always attempt to lock the file before writing, you can ensure that only one write access is made at a time. You must always follow up with a flush and unlock.
It's recommended that if FLAGS_READ_THROUGH_LOCK_BIT
is set
that you not write to the index file since the structure of the index file may
change out from under other processes accessing this file at the same time.
After locking for the first time (TBLT_KH.lockCount = 0), and before making any
access to the index file, this routine automatically calls
BltIx4ReadHeader()
to load the index file header from disk into
TBLT_KH. If this TBLT_KH has been locked previously, the header is not
reloaded; instead the TBLT_KH.lockCount is incremented one.
If an atomic lock, and the lock is going from exclusive to shared, the header is flushed before the lock is made (a shared lock allows only read-only access).
Returns: Returns Non-zero indicates an error, otherwise the
entire index file is locked.