diff options
Diffstat (limited to 'bdb/hash/hash_meta.c')
-rw-r--r-- | bdb/hash/hash_meta.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/bdb/hash/hash_meta.c b/bdb/hash/hash_meta.c index d96a6db3207..9f224454869 100644 --- a/bdb/hash/hash_meta.c +++ b/bdb/hash/hash_meta.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999, 2000 + * Copyright (c) 1999-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "$Id: hash_meta.c,v 11.10 2000/12/21 21:54:35 margo Exp $"; +static const char revid[] = "$Id: hash_meta.c,v 11.19 2002/06/03 14:22:15 ubell Exp $"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -16,11 +16,10 @@ static const char revid[] = "$Id: hash_meta.c,v 11.10 2000/12/21 21:54:35 margo #endif #include "db_int.h" -#include "db_page.h" -#include "hash.h" -#include "db_shash.h" -#include "lock.h" -#include "txn.h" +#include "dbinc/db_page.h" +#include "dbinc/db_shash.h" +#include "dbinc/hash.h" +#include "dbinc/lock.h" /* * Acquire the meta-data page. @@ -31,30 +30,32 @@ int __ham_get_meta(dbc) DBC *dbc; { - HASH_CURSOR *hcp; - HASH *hashp; DB *dbp; + DB_ENV *dbenv; + DB_MPOOLFILE *mpf; + HASH *hashp; + HASH_CURSOR *hcp; int ret; - hcp = (HASH_CURSOR *)dbc->internal; dbp = dbc->dbp; + dbenv = dbp->dbenv; + mpf = dbp->mpf; hashp = dbp->h_internal; + hcp = (HASH_CURSOR *)dbc->internal; - if (dbp->dbenv != NULL && - STD_LOCKING(dbc) && !F_ISSET(dbc, DBC_RECOVER)) { + if (dbenv != NULL && + STD_LOCKING(dbc) && !F_ISSET(dbc, DBC_RECOVER | DBC_COMPENSATE)) { dbc->lock.pgno = hashp->meta_pgno; - if ((ret = lock_get(dbp->dbenv, dbc->locker, + if ((ret = dbenv->lock_get(dbenv, dbc->locker, DB_NONBLOCK(dbc) ? DB_LOCK_NOWAIT : 0, &dbc->lock_dbt, DB_LOCK_READ, &hcp->hlock)) != 0) return (ret); } - if ((ret = memp_fget(dbc->dbp->mpf, + if ((ret = mpf->get(mpf, &hashp->meta_pgno, DB_MPOOL_CREATE, &(hcp->hdr))) != 0 && - hcp->hlock.off != LOCK_INVALID) { - (void)lock_put(dbc->dbp->dbenv, &hcp->hlock); - hcp->hlock.off = LOCK_INVALID; - } + LOCK_ISSET(hcp->hlock)) + (void)dbenv->lock_put(dbenv, &hcp->hlock); return (ret); } @@ -68,18 +69,19 @@ int __ham_release_meta(dbc) DBC *dbc; { + DB_MPOOLFILE *mpf; HASH_CURSOR *hcp; + mpf = dbc->dbp->mpf; hcp = (HASH_CURSOR *)dbc->internal; if (hcp->hdr) - (void)memp_fput(dbc->dbp->mpf, hcp->hdr, + (void)mpf->put(mpf, hcp->hdr, F_ISSET(hcp, H_DIRTY) ? DB_MPOOL_DIRTY : 0); hcp->hdr = NULL; - if (!F_ISSET(dbc, DBC_RECOVER) && - dbc->txn == NULL && hcp->hlock.off != LOCK_INVALID) - (void)lock_put(dbc->dbp->dbenv, &hcp->hlock); - hcp->hlock.off = LOCK_INVALID; + if (!F_ISSET(dbc, DBC_RECOVER | DBC_COMPENSATE) && + dbc->txn == NULL && LOCK_ISSET(hcp->hlock)) + (void)dbc->dbp->dbenv->lock_put(dbc->dbp->dbenv, &hcp->hlock); F_CLR(hcp, H_DIRTY); return (0); @@ -95,6 +97,7 @@ __ham_dirty_meta(dbc) DBC *dbc; { DB *dbp; + DB_ENV *dbenv; DB_LOCK _tmp; HASH *hashp; HASH_CURSOR *hcp; @@ -105,12 +108,13 @@ __ham_dirty_meta(dbc) hcp = (HASH_CURSOR *)dbc->internal; ret = 0; - if (STD_LOCKING(dbc) && !F_ISSET(dbc, DBC_RECOVER)) { + if (STD_LOCKING(dbc) && !F_ISSET(dbc, DBC_RECOVER | DBC_COMPENSATE)) { + dbenv = dbp->dbenv; dbc->lock.pgno = hashp->meta_pgno; - if ((ret = lock_get(dbp->dbenv, dbc->locker, + if ((ret = dbenv->lock_get(dbenv, dbc->locker, DB_NONBLOCK(dbc) ? DB_LOCK_NOWAIT : 0, &dbc->lock_dbt, DB_LOCK_WRITE, &_tmp)) == 0) { - ret = lock_put(dbp->dbenv, &hcp->hlock); + ret = dbenv->lock_put(dbenv, &hcp->hlock); hcp->hlock = _tmp; } } |