Guardian Procedure Calls Reference Manual
locked). The alternate locking mode is specified by calling the SETMODE procedure and
specifying function 4.
• Attempting to read a locked record in default locking mode
If the default locking mode is in effect when READ or READUPDATE is called for a record that
is locked by another user, the caller to READ or READUPDATE is suspended and queued in
the "locking" queue behind other users attempting to lock or read the record. (Another "user"
means another open filenum if the file is not audited, or another TRANSID if the file is
audited.)
NOTE: For non-audited files, a deadlock condition—a permanent suspension of your
application—occurs if READ or READUPDATE is called by the process which has a record
locked by a filenum other than that supplied to READ or READUPDATE. (For an explanation
of multiple opens by the same process, see the FILE_OPEN_ or OPEN procedure.)
• Selecting the locking mode with SETMODE
The locking mode is specified by the SETMODE procedure with function = 4.
• A count of the locks in effect is not maintained. Multiple locks can be unlocked with one call
to UNLOCKFILE. For example:
CALL LOCKREC ( file^a,... ); ! locks the current record
! in "file^a."
CALL LOCKREC ( file^a,... ); ! has no effect since the
! current record is already
! locked.
CALL UNLOCKREC (file^a,...); ! unlocks the current record
! in "file^a."
CALL UNLOCKREC (file^a,...); ! has no effect since the
! current record is not
! locked.
• Structured files
Calling LOCKREC after positioning on a nonunique key
If the call to LOCKREC immediately follows a call to KEYPOSITION where a nonunique
alternate key is specified, the LOCKREC fails. A subsequent call to FILE_GETINFO_ or
◦
FILEINFO shows that an error 46 (invalid key) occurred. However, if an intermediate call
to READ is performed, the call to LOCKREC is permitted because a unique record is
identified.
◦ Current-state indicators after LOCKREC
After a successful LOCKREC, current-state indicators are unchanged.
• Unstructured files
Locking the RBA in an unstructured file
Record positions in an unstructured file are represented by an RBA, and the RBA can be
locked with LOCKREC. To lock a position in an unstructured file, first call POSITION with
◦
the desired RBA, and then call LOCKREC. This locks the RBA; any other process attempting
to access the file with exactly the same RBA encounters a "record is locked condition."
You can access that RBA by positioning to RBA-2. Depending on the process' locking
LOCKREC Procedure 777