Berkeley DB Reference Version 5.3.33

DB_ENV->lock_vec()

#include <db.h>

int
DB_ENV->lock_vec(DB_ENV *env, u_int32_t locker, u_int32_t flags,
    DB_LOCKREQ list[], int nlist, DB_LOCKREQ **elistp);  

The DB_ENV->lock_vec() method atomically obtains and releases one or more locks from the lock table. The DB_ENV->lock_vec() method is intended to support acquisition or trading of multiple locks under one lock table semaphore, as is needed for lock coupling or in multigranularity locking for lock escalation.

If any of the requested locks cannot be acquired, or any of the locks to be released cannot be released, the operations before the failing operation are guaranteed to have completed successfully, and DB_ENV->lock_vec() returns a non-zero value. In addition, if elistp is not NULL, it is set to point to the DB_LOCKREQ entry that was being processed when the error occurred.

Unless otherwise specified, the DB_ENV->lock_vec() method returns a non-zero error value on failure and 0 on success.

Parameters

locker

The locker parameter is an unsigned 32-bit integer quantity. It represents the entity requesting or releasing the lock.

flags

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

list

The list array provided to DB_ENV->lock_vec() is typedef'd as DB_LOCKREQ.

To ensure compatibility with future releases of Berkeley DB, all fields of the DB_LOCKREQ structure that are not explicitly set should be initialized to 0 before the first time the structure is used. Do this by declaring the structure external or static, or by calling memset(3).

A DB_LOCKREQ structure has at least the following fields:

nlist

The nlist parameter specifies the number of elements in the list array.

elistp

If an error occurs, and the elistp parameter is non-NULL, it is set to point to the DB_LOCKREQ entry that was being processed when the error occurred.

Errors

The DB_ENV->lock_vec() method may fail and return one of the following non-zero errors:

DB_LOCK_DEADLOCK

A transactional database environment operation was selected to resolve a deadlock.

DB_LOCK_NOTGRANTED

A Berkeley DB Concurrent Data Store database environment configured for lock timeouts was unable to grant a lock in the allowed time.

You attempted to open a database handle that is configured for no waiting exclusive locking, but the exclusive lock could not be immediately obtained. See DB->set_lk_exclusive() for more information.

DB_LOCK_NOTGRANTED

The DB_LOCK_NOWAIT flag or lock timers were configured and the lock could not be granted before the wait-time expired.

EINVAL

An invalid flag value or parameter was specified.

ENOMEM

The maximum number of locks has been reached.

Class

DB_ENV, DB_LOCK

See Also

Locking Subsystem and Related Methods