/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
#include "config.h"
#ifndef lint
static const char sccsid[] = "@(#)lock.c 10.52 (Sleepycat) 5/10/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#include <errno.h>
#include <string.h>
#endif
#include "db_int.h"
#include "shqueue.h"
#include "db_page.h"
#include "db_shash.h"
#include "lock.h"
#include "common_ext.h"
#include "db_am.h"
static void __lock_checklocker __P((DB_LOCKTAB *, struct __db_lock *, int));
static void __lock_freeobj __P((DB_LOCKTAB *, DB_LOCKOBJ *));
static int __lock_get_internal __P((DB_LOCKTAB *, u_int32_t, u_int32_t,
const DBT *, db_lockmode_t, struct __db_lock **));
static int __lock_put_internal __P((DB_LOCKTAB *, struct __db_lock *, int));
static void __lock_remove_waiter
__P((DB_LOCKTAB *, DB_LOCKOBJ *, struct __db_lock *, db_status_t));
int
lock_id(lt, idp)
DB_LOCKTAB *lt;
u_int32_t *idp;
{
u_int32_t id;
LOCK_LOCKREGION(lt);
if (lt->region->id >= DB_LOCK_MAXID)
lt->region->id = 0;
id = ++lt->region->id;
UNLOCK_LOCKREGION(lt);
*idp = id;
return (0);
}
int
lock_vec(lt, locker, flags, list, nlist, elistp)
DB_LOCKTAB *lt;
u_int32_t locker, flags;
int nlist;
DB_LOCKREQ *list, **elistp;
{
struct __db_lock *lp;
DB_LOCKOBJ *sh_obj, *sh_locker;
int i, ret, run_dd;
/* Validate arguments. */
if ((ret =
__db_fchk(lt->dbenv, "lock_vec", <