lock_get

APIRef

#include <db.h>

int lock_get(DB_ENV *env, u_int32_t locker, u_int32_t flags, const DBT *obj, const db_lockmode_t lock_mode, DB_LOCK *lock);

Description

The lock_get function acquires a lock from the lock table, returning information about it in the lock argument.

The locker argument specified to lock_get is an unsigned 32-bit integer quantity. It represents the entity requesting or releasing the lock.

The flags value must be set to 0 or the following value:

DB_LOCK_NOWAIT
If a lock cannot be granted because the requested lock conflicts with an existing lock, return immediately instead of waiting for the lock to become available.

The obj argument is an untyped byte string that specifies the object to be locked or released.

The mode argument is an index into the environment's lock conflict array. See DBENV->set_lk_conflicts and Standard Lock Modes for a description of that array.

The lock_get function may return one of the following values:

DB_LOCK_NOTGRANTED
A lock was requested that could not be immediately granted and the flags parameter was set to DB_LOCK_NOWAIT.

Otherwise, the lock_get function returns a non-zero error value on failure and 0 on success.

Errors

The lock_get function may fail and return a non-zero error for the following conditions:

DB_LOCK_DEADLOCK
The operation was selected to resolve a deadlock.

EINVAL
An invalid flag value or parameter was specified.

ENOMEM
The maximum number of locks has been reached.

The lock_get function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. If a catastrophic error has occurred, the lock_get function may fail and return DB_RUNRECOVERY, in which case all subsequent Berkeley DB calls will fail in the same way.

See Also

DBENV->set_lk_conflicts, DBENV->set_lk_detect, DBENV->set_lk_max, lock_detect, lock_get, lock_id, lock_put, lock_stat and lock_vec.

APIRef

Copyright Sleepycat Software