BltLockDataRecord


< Prev  TOC  Next >

TBLT_RETC TBLT_ENTRY BltLockDataRecord(TBLT_DH *dhPtr,
                                       ULONG mode,
                                       ULONG recNoStart,
                                       ULONG recCount,
                                       ULONG timeout);


 dhPtr          I:data file control structure
 mode           I:lock type
 recNoStart     I:record number to start lock at, or 0
 recCount       I:number of records to lock from recNoStart
 timeout        I:timeout, in milliseconds

This routine locks the data file, either all or selected records

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_ATOMIC
Atomic 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.

To lock the entire data file, including the header, set recNoStart = 0 (recCount is not used when recNoStart = 0). Doing this automatically calls BltDataReadHeader() if this is the first outstanding full lock (otherwise, the full lock count is simply incremented one for this TBLT_DH).

To lock a particular record, or series of records, set recNoStart to the first record to lock and recCount to the number of records to lock, starting at recNoStart. The first record is record number 1.

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_BIT
specified. 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 lockix4.c and lockdata.c files cover this technique.

After locking a record(s) (ie, if recNoStart is not 0), and before making any access to the data file, you must call BltDataReadHeader() to load the data file header from disk into TBLT_DH (locking the data header first is recommended). It's recommended that if FLAGS_READ_THROUGH_LOCK_BIT is set that you not write to the data file since the structure (the number of records) of the data file may change out from under other processes accessing this file at the same time.

Returns: Non-zero indicates an error, otherwise the specified record(s), or the entire file, is locked.


All content Copyright © 1999 Cornel Huth. All rights reserved.