UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Macros | Functions
dblocks.h File Reference
#include <mix/ErrCodes.h>
#include <mix/locks.h>
#include <ldb/dbtc.h>

Go to the source code of this file.

Classes

struct  DbLockDescr
 

Macros

#define DB_LOCK_TRIES   3
 
#define DB_LOCK_MAX_DELAY   300000
 
#define DB_LOCK_UNKNOWN_ID   ((DbIndex)(-1))
 
#define DB_LOCK_EXCL_FNAME_EXT   ".exl"
 
#define DB_LOCK_SHARED_FNAME_EXT   ".lac"
 
#define DB_LOCK_READ_ONLY   "ro"
 
#define DB_LOCK_READ_WRITE   "rw"
 

Functions

ErrCode LockDbResource (LockId *plid, const char *project, const dbNameStruct *dbns, DbAccess dbac)
 
ErrCode LockDbResourceByName (LockId *plid, const char *project, const char *dbname, DbAccess dbac)
 
ErrCode RelockDbResource (LockId lid, const char *project, const dbNameStruct *dbns, DbAccess new_dbac)
 
ErrCode RelockDbResourceByName (LockId lid, const char *project, const char *dbname, DbAccess new_dbac)
 
ErrCode CheckLockedDbResource (const char *project, const dbNameStruct *dbns, unsigned *ndescr, DbLockDescr **ldescr)
 
ErrCode ReleaseLockOfDbResource (const char *project, const dbNameStruct *dbns, LockId lid)
 
ErrCode ReleaseDbResource (const char *project, const dbNameStruct *dbns)
 

Detailed Description

Application programming interface for data base tables and trace modifications lock/unlock operations.

Macro Definition Documentation

#define DB_LOCK_EXCL_FNAME_EXT   ".exl"

Suffix of exclusive lock file name: EXclusive Lock

#define DB_LOCK_MAX_DELAY   300000

Delay between attemps a random delay take place (maximum value in microseconds).

#define DB_LOCK_READ_ONLY   "ro"

Symbolic string for read-only lock

#define DB_LOCK_READ_WRITE   "rw"

Symbolic string for read-write lock

#define DB_LOCK_SHARED_FNAME_EXT   ".lac"

Suffix of shared lock file name: Lock's Access Control db table

#define DB_LOCK_TRIES   3

If some db lock can't be made due to ERROR__SHARED_REFUSED, given numbers of attempts will be made.

#define DB_LOCK_UNKNOWN_ID   ((DbIndex)(-1))

"Given LockId is not found" value

Function Documentation

ErrCode CheckLockedDbResource ( const char *  project,
const dbNameStruct dbns,
unsigned *  ndescr,
DbLockDescr **  ldescr 
)

Check for locked a db object inside the project. Do not care about very time dependence of lock state information. Returns OK if information of db lock can be obtained or error code describing them failure reason. *ndescr contains current number of locks and ldescr contains calloc() allocated lock descriptions. Both ndescr and ldescr may be NULL.

"By name" version may be producted by using dbBuildFileName() call.

ErrCode LockDbResource ( LockId *  plid,
const char *  project,
const dbNameStruct dbns,
DbAccess  dbac 
)

Make sharable lock of a db object inside the project. In opposition to class DbLock this routine tries to lock an object several times with small delays.

ErrCode LockDbResourceByName ( LockId *  plid,
const char *  project,
const char *  dbname,
DbAccess  dbac 
)

Make sharable lock of a db object inside the project. In opposition to class DbLock this routine tries to lock an object several times with small delays.

ErrCode ReleaseDbResource ( const char *  project,
const dbNameStruct dbns 
)

Entirely unlock db object by removing ALL shareable locks.

DANGER! It doesn't check for live locks, so has a gate to unreliable simultaneous access to the same db object from many applications. Removes only db lock, so can't be used for unlocking exclusively locked db objects. Use ReleaseResource() for this purpose instead (see mix/locks.h)

ErrCode ReleaseLockOfDbResource ( const char *  project,
const dbNameStruct dbns,
LockId  lid 
)

Unlock db object by given lock id.

DANGER! It doesn't check for live lock, so has a gate to unreliable simultaneous access to the same db object from many applications. Removes only db lock, so can't be used for unlocking exclusively locked db objects. Use ReleaseResource() for this purpose instead (see mix/locks.h)

ErrCode RelockDbResource ( LockId  lid,
const char *  project,
const dbNameStruct dbns,
DbAccess  new_dbac 
)

Change mode of sharable lock (lid) of a db object inside the project. This routine tries to lock an object several times with small delays. This implementation now does not use lid at all because LockId is a internal number inside LockManager, but we can't find it in DbLockTable from outside. Lock id can be used in future implementations.

ErrCode RelockDbResourceByName ( LockId  lid,
const char *  project,
const char *  dbname,
DbAccess  new_dbac 
)

Change mode of sharable lock (lid) of a db object inside the project. This routine tries to lock an object several times with small delays. This implementation now does not use lid at all because LockId is a internal number inside LockManager, but we can't find it in DbLockTable from outside. Lock id can be used in future implementations.