dbLock.h

Lock one or multiple records.

Locking is required to prevent corruption of record fields due to concurrent access by different threads.

Typedefs

typedef struct dbLocker dbLocker

Functions

void dbScanLock(struct dbCommon *precord)

Lock a record for modification.

While locked, caller may access record using eg. dbGet() or dbPut(), but not dbGetField() or dbPutField(). The caller must later call dbScanUnlock(). dbScanLock() may be called again as the record lock behaves as a recursive mutex.

void dbScanUnlock(struct dbCommon *precord)

Unlock a record.

Reverse the action of dbScanLock()

dbLocker *dbLockerAlloc(struct dbCommon *const *precs, size_t nrecs, unsigned int flags)

Prepare to lock a set of records.

Since

3.16.0.1

Parameters:
  • precs – Array of nrecs dbCommon pointers.

  • nrecs – Length of precs array

  • flags – Set to 0

Returns:

NULL on error

void dbLockerFree(dbLocker *plocker)

Free dbLocker allocated by dbLockerAlloc()

Since

3.16.0.1

Parameters:

plocker – Must not be NULL

void dbScanLockMany(dbLocker*)

Lock all records of dbLocker.

Locks multiple record. While locked, caller may access any associated record passed to dbLockerAlloc(). dbScanLockMany() may not be called again (multi-lock is not recursive). dbScanLock()/dbScanUnlock() may be called on individual record. The caller must later call dbScanUnlockMany().

Since

3.16.0.1

void dbScanUnlockMany(dbLocker*)

Unlock all records of dbLocker.

Unlocks the records of dbLocker. A thread must call dbScanUnlockMany with the same dbLocker* before calling dbScanLockMany again.

Since

3.16.0.1

unsigned long dbLockGetLockId(struct dbCommon *precord)

Returns ID number of the lockset.

void dbLockInitRecords(struct dbBase *pdbbase)

During IOC startup the complete list of records is iterated by dbLockInitRecords.

The required locksets are created and populated based on the links defined at the time of IOC startup

void dbLockCleanupRecords(struct dbBase *pdbbase)

Frees up locksets which are no longer in use. If lockset is still active, prints warning and calls dblsr

long dblsr(char *recordname, int level)

Lock Set Report.

Generates a report showing the lock set to which each record belongs. If recordname is 0, “”, “*” all records are shown. Otherwise only records in the same lock set as recordname are shown. Level can have the following values:

0 - show lock set information only

1 - show each record in the lock set

2 - show each record and all database links in the lock set

long dbLockShowLocked(int level)

Displays free and active locksets.

int *dbLockSetAddrTrace(struct dbCommon *precord)

Support for TPRO field.

unsigned long dbLockGetRefs(struct dbCommon*)

Returns the reference count.

unsigned long dbLockCountSets(void)

Returns the number of active locksets.