summaryrefslogtreecommitdiff
path: root/bdb/env/env_region.c
diff options
context:
space:
mode:
Diffstat (limited to 'bdb/env/env_region.c')
-rw-r--r--bdb/env/env_region.c247
1 files changed, 149 insertions, 98 deletions
diff --git a/bdb/env/env_region.c b/bdb/env/env_region.c
index f3df4bac184..a919cf328b4 100644
--- a/bdb/env/env_region.c
+++ b/bdb/env/env_region.c
@@ -1,14 +1,14 @@
/*-
* See the file LICENSE for redistribution information.
*
- * Copyright (c) 1996, 1997, 1998, 1999, 2000
+ * Copyright (c) 1996-2002
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
-static const char revid[] = "$Id: env_region.c,v 11.28 2000/12/12 17:36:10 bostic Exp $";
+static const char revid[] = "$Id: env_region.c,v 11.64 2002/07/17 15:09:19 bostic Exp $";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
@@ -20,20 +20,17 @@ static const char revid[] = "$Id: env_region.c,v 11.28 2000/12/12 17:36:10 bosti
#endif
#include "db_int.h"
-#include "db_shash.h"
-#include "lock.h"
-#include "lock_ext.h"
-#include "log.h"
-#include "log_ext.h"
-#include "mp.h"
-#include "mp_ext.h"
-#include "txn.h"
-#include "txn_ext.h"
+#include "dbinc/db_shash.h"
+#include "dbinc/lock.h"
+#include "dbinc/log.h"
+#include "dbinc/mp.h"
+#include "dbinc/rep.h"
+#include "dbinc/txn.h"
static int __db_des_destroy __P((DB_ENV *, REGION *));
static int __db_des_get __P((DB_ENV *, REGINFO *, REGINFO *, REGION **));
static int __db_e_remfile __P((DB_ENV *));
-static int __db_faultmem __P((void *, size_t, int));
+static int __db_faultmem __P((DB_ENV *, void *, size_t, int));
static void __db_region_destroy __P((DB_ENV *, REGINFO *));
/*
@@ -110,13 +107,17 @@ loop: renv = NULL;
* If this is a public environment, we use the filesystem to ensure
* the creation of the environment file is single-threaded.
*/
- if (F_ISSET(dbenv, DB_ENV_PRIVATE))
+ if (F_ISSET(dbenv, DB_ENV_PRIVATE)) {
+ if ((ret = __os_strdup(dbenv,
+ "process-private", &infop->name)) != 0)
+ goto err;
goto creation;
+ }
/* Build the region name. */
(void)snprintf(buf, sizeof(buf), "%s", DB_REGION_ENV);
if ((ret = __db_appname(dbenv,
- DB_APP_NONE, NULL, buf, 0, NULL, &infop->name)) != 0)
+ DB_APP_NONE, buf, 0, NULL, &infop->name)) != 0)
goto err;
/*
@@ -128,8 +129,8 @@ loop: renv = NULL;
* errno return value -- I sure hope they're right.
*/
if (F_ISSET(dbenv, DB_ENV_CREATE)) {
- if ((ret = __os_open(dbenv,
- infop->name, DB_OSO_REGION | DB_OSO_CREATE | DB_OSO_EXCL,
+ if ((ret = __os_open(dbenv, infop->name,
+ DB_OSO_CREATE | DB_OSO_DIRECT | DB_OSO_EXCL | DB_OSO_REGION,
dbenv->db_mode, dbenv->lockfhp)) == 0)
goto creation;
if (ret != EEXIST) {
@@ -143,8 +144,8 @@ loop: renv = NULL;
* If we couldn't create the file, try and open it. (If that fails,
* we're done.)
*/
- if ((ret = __os_open(dbenv, infop->name,
- DB_OSO_REGION, dbenv->db_mode, dbenv->lockfhp)) != 0)
+ if ((ret = __os_open(dbenv, infop->name, DB_OSO_REGION | DB_OSO_DIRECT,
+ dbenv->db_mode, dbenv->lockfhp)) != 0)
goto err;
/*
@@ -230,12 +231,12 @@ loop: renv = NULL;
* the better.
*/
#ifdef HAVE_MUTEX_THREADS
- __os_closehandle(dbenv->lockfhp);
+ __os_closehandle(dbenv, dbenv->lockfhp);
#endif
/* Call the region join routine to acquire the region. */
memset(&tregion, 0, sizeof(tregion));
- tregion.size = size;
+ tregion.size = (roff_t)size;
tregion.segid = segid;
if ((ret = __os_r_attach(dbenv, infop, &tregion)) != 0)
goto err;
@@ -265,7 +266,7 @@ loop: renv = NULL;
* can't because Windows/NT filesystems won't open files mode 0.
*/
renv = infop->primary;
- if (renv->panic) {
+ if (renv->envpanic && !F_ISSET(dbenv, DB_ENV_NOPANIC)) {
ret = __db_panic_msg(dbenv);
goto err;
}
@@ -287,13 +288,13 @@ loop: renv = NULL;
}
/* Lock the environment. */
- MUTEX_LOCK(dbenv, &renv->mutex, dbenv->lockfhp);
+ MUTEX_LOCK(dbenv, &renv->mutex);
/*
* Finally! We own the environment now. Repeat the panic check, it's
* possible that it was set while we waited for the lock.
*/
- if (renv->panic) {
+ if (renv->envpanic && !F_ISSET(dbenv, DB_ENV_NOPANIC)) {
ret = __db_panic_msg(dbenv);
goto err_unlock;
}
@@ -338,7 +339,7 @@ err_unlock: MUTEX_UNLOCK(dbenv, &renv->mutex);
* Fault the pages into memory. Note, do this AFTER releasing the
* lock, because we're only reading the pages, not writing them.
*/
- (void)__db_faultmem(infop->primary, rp->size, 0);
+ (void)__db_faultmem(dbenv, infop->primary, rp->size, 0);
/* Everything looks good, we're done. */
dbenv->reginfo = infop;
@@ -352,9 +353,12 @@ creation:
* Allocate room for 50 REGION structures plus overhead (we're going
* to use this space for last-ditch allocation requests), although we
* should never need anything close to that.
+ *
+ * Encryption passwds are stored in the env region. Add that in too.
*/
memset(&tregion, 0, sizeof(tregion));
- tregion.size = 50 * sizeof(REGION) + 50 * sizeof(MUTEX) + 2048;
+ tregion.size = (roff_t)(50 * sizeof(REGION) +
+ dbenv->passwd_len + 2048);
tregion.segid = INVALID_REGION_SEGID;
if ((ret = __os_r_attach(dbenv, infop, &tregion)) != 0)
goto err;
@@ -363,7 +367,7 @@ creation:
* Fault the pages into memory. Note, do this BEFORE we initialize
* anything, because we're writing the pages, not just reading them.
*/
- (void)__db_faultmem(infop->addr, tregion.size, 1);
+ (void)__db_faultmem(dbenv, infop->addr, tregion.size, 1);
/*
* The first object in the region is the REGENV structure. This is
@@ -392,10 +396,12 @@ creation:
* number which validates the file/environment.
*/
renv = infop->primary;
- renv->panic = 0;
+ renv->envpanic = 0;
db_version(&renv->majver, &renv->minver, &renv->patch);
SH_LIST_INIT(&renv->regionq);
renv->refcnt = 1;
+ renv->cipher_off = INVALID_ROFF;
+ renv->rep_off = INVALID_ROFF;
/*
* Initialize init_flags to store the flags that any other environment
@@ -412,15 +418,15 @@ creation:
* filesystem as the database home. But you knew that, I'm sure -- it
* probably wasn't even worth mentioning.)
*/
- if ((ret =
- __db_mutex_init(dbenv, &renv->mutex, DB_FCNTL_OFF_GEN, 0)) != 0) {
+ if ((ret = __db_mutex_setup(dbenv, infop, &renv->mutex,
+ MUTEX_NO_RECORD | MUTEX_NO_RLOCK)) != 0) {
__db_err(dbenv, "%s: unable to initialize environment lock: %s",
infop->name, db_strerror(ret));
goto err;
}
if (!F_ISSET(&renv->mutex, MUTEX_IGNORE) &&
- (ret = __db_mutex_lock(dbenv, &renv->mutex, dbenv->lockfhp)) != 0) {
+ (ret = __db_mutex_lock(dbenv, &renv->mutex)) != 0) {
__db_err(dbenv, "%s: unable to acquire environment lock: %s",
infop->name, db_strerror(ret));
goto err;
@@ -459,8 +465,8 @@ find_err: __db_err(dbenv,
if (tregion.segid != INVALID_REGION_SEGID) {
ref.size = tregion.size;
ref.segid = tregion.segid;
- if ((ret = __os_write(dbenv, dbenv->lockfhp,
- &ref, sizeof(ref), &nrw)) != 0 || nrw != sizeof(ref)) {
+ if ((ret = __os_write(
+ dbenv, dbenv->lockfhp, &ref, sizeof(ref), &nrw)) != 0) {
__db_err(dbenv,
"%s: unable to write out public environment ID: %s",
infop->name, db_strerror(ret));
@@ -476,7 +482,7 @@ find_err: __db_err(dbenv,
*/
#if defined(HAVE_MUTEX_THREADS)
if (F_ISSET(dbenv->lockfhp, DB_FH_VALID))
- __os_closehandle(dbenv->lockfhp);
+ __os_closehandle(dbenv, dbenv->lockfhp);
#endif
/* Validate the file. */
@@ -492,7 +498,7 @@ find_err: __db_err(dbenv,
err:
retry: /* Close any open file handle. */
if (F_ISSET(dbenv->lockfhp, DB_FH_VALID))
- (void)__os_closehandle(dbenv->lockfhp);
+ (void)__os_closehandle(dbenv, dbenv->lockfhp);
/*
* If we joined or created the region, detach from it. If we created
@@ -513,8 +519,8 @@ retry: /* Close any open file handle. */
/* Free the allocated name and/or REGINFO structure. */
if (infop->name != NULL)
- __os_freestr(infop->name);
- __os_free(infop, sizeof(REGINFO));
+ __os_free(dbenv, infop->name);
+ __os_free(dbenv, infop);
/* If we had a temporary error, wait awhile and try again. */
if (ret == 0) {
@@ -547,8 +553,10 @@ __db_e_detach(dbenv, destroy)
infop = dbenv->reginfo;
renv = infop->primary;
+ if (F_ISSET(dbenv, DB_ENV_PRIVATE))
+ destroy = 1;
/* Lock the environment. */
- MUTEX_LOCK(dbenv, &renv->mutex, dbenv->lockfhp);
+ MUTEX_LOCK(dbenv, &renv->mutex);
/* Decrement the reference count. */
if (renv->refcnt == 0) {
@@ -563,33 +571,39 @@ __db_e_detach(dbenv, destroy)
/* Close the locking file handle. */
if (F_ISSET(dbenv->lockfhp, DB_FH_VALID))
- (void)__os_closehandle(dbenv->lockfhp);
+ (void)__os_closehandle(dbenv, dbenv->lockfhp);
/* Reset the addr value that we "corrected" above. */
infop->addr = infop->primary;
/*
* If we are destroying the environment, we need to
- * destroy any system resources backing the mutex.
- * Do that now before we free the memory in __os_r_detach.
+ * destroy any system resources backing the mutex, as well
+ * as any system resources that the replication system may have
+ * acquired and put in the main region.
+ *
+ * Do these now before we free the memory in __os_r_detach.
*/
- if (destroy)
+ if (destroy) {
+ __rep_region_destroy(dbenv);
__db_mutex_destroy(&renv->mutex);
+ __db_mutex_destroy(&infop->rp->mutex);
+ }
/*
* Release the region, and kill our reference.
*
- * We set the DBENV->reginfo field to NULL here and discard its memory.
- * DBENV->remove calls __dbenv_remove to do the region remove, and
+ * We set the DB_ENV->reginfo field to NULL here and discard its memory.
+ * DB_ENV->remove calls __dbenv_remove to do the region remove, and
* __dbenv_remove attached and then detaches from the region. We don't
- * want to return to DBENV->remove with a non-NULL DBENV->reginfo field
- * because it will attempt to detach again as part of its cleanup.
+ * want to return to DB_ENV->remove with a non-NULL DB_ENV->reginfo
+ * field because it will attempt to detach again as part of its cleanup.
*/
(void)__os_r_detach(dbenv, infop, destroy);
if (infop->name != NULL)
- __os_free(infop->name, 0);
- __os_free(dbenv->reginfo, sizeof(REGINFO));
+ __os_free(dbenv, infop->name);
+ __os_free(dbenv, dbenv->reginfo);
dbenv->reginfo = NULL;
return (0);
@@ -599,18 +613,20 @@ __db_e_detach(dbenv, destroy)
* __db_e_remove --
* Discard an environment if it's not in use.
*
- * PUBLIC: int __db_e_remove __P((DB_ENV *, int));
+ * PUBLIC: int __db_e_remove __P((DB_ENV *, u_int32_t));
*/
int
-__db_e_remove(dbenv, force)
+__db_e_remove(dbenv, flags)
DB_ENV *dbenv;
- int force;
+ u_int32_t flags;
{
REGENV *renv;
REGINFO *infop, reginfo;
REGION *rp;
- int ret;
+ u_int32_t db_env_reset;
+ int force, ret;
+ force = LF_ISSET(DB_FORCE) ? 1 : 0;
/*
* This routine has to walk a nasty line between not looking into
* the environment (which may be corrupted after an app or system
@@ -632,8 +648,10 @@ __db_e_remove(dbenv, force)
* If the force flag is set, we do not acquire any locks during this
* process.
*/
+ db_env_reset = F_ISSET(dbenv, DB_ENV_NOLOCKING | DB_ENV_NOPANIC);
if (force)
- dbenv->db_mutexlocks = 0;
+ F_SET(dbenv, DB_ENV_NOLOCKING);
+ F_SET(dbenv, DB_ENV_NOPANIC);
/* Join the environment. */
if ((ret = __db_e_attach(dbenv, NULL)) != 0) {
@@ -645,17 +663,21 @@ __db_e_remove(dbenv, force)
ret = 0;
if (force)
goto remfiles;
- goto err;
+ goto done;
}
infop = dbenv->reginfo;
renv = infop->primary;
/* Lock the environment. */
- MUTEX_LOCK(dbenv, &renv->mutex, dbenv->lockfhp);
+ MUTEX_LOCK(dbenv, &renv->mutex);
- /* If it's in use, we're done. */
- if (renv->refcnt == 1 || force) {
+ /*
+ * If it's in use, we're done unless we're forcing the issue or the
+ * environment has panic'd. (Presumably, if the environment panic'd,
+ * the thread holding the reference count may not have cleaned up.)
+ */
+ if (renv->refcnt == 1 || renv->envpanic == 1 || force) {
/*
* Set the panic flag and overwrite the magic number.
*
@@ -663,7 +685,7 @@ __db_e_remove(dbenv, force)
* From this point on, there's no going back, we pretty
* much ignore errors, and just whack on whatever we can.
*/
- renv->panic = 1;
+ renv->envpanic = 1;
renv->magic = 0;
/*
@@ -713,7 +735,7 @@ restart: for (rp = SH_LIST_FIRST(&renv->regionq, __db_region);
/* Destroy the environment's region. */
(void)__db_e_detach(dbenv, 1);
- /* Discard the physical files. */
+ /* Discard any remaining physical files. */
remfiles: (void)__db_e_remfile(dbenv);
} else {
/* Unlock the environment. */
@@ -725,7 +747,9 @@ remfiles: (void)__db_e_remfile(dbenv);
ret = EBUSY;
}
-err:
+done: F_CLR(dbenv, DB_ENV_NOLOCKING | DB_ENV_NOPANIC);
+ F_SET(dbenv, db_env_reset);
+
return (ret);
}
@@ -742,7 +766,7 @@ __db_e_remfile(dbenv)
"__db_log.share",
"__db_mpool.share",
"__db_txn.share",
- NULL,
+ NULL
};
int cnt, fcnt, lastrm, ret;
u_int8_t saved_byte;
@@ -751,8 +775,7 @@ __db_e_remfile(dbenv)
/* Get the full path of a file in the environment. */
(void)snprintf(buf, sizeof(buf), "%s", DB_REGION_ENV);
- if ((ret =
- __db_appname(dbenv, DB_APP_NONE, NULL, buf, 0, NULL, &path)) != 0)
+ if ((ret = __db_appname(dbenv, DB_APP_NONE, buf, 0, NULL, &path)) != 0)
return (ret);
/* Get the parent directory for the environment. */
@@ -769,16 +792,15 @@ __db_e_remfile(dbenv)
}
/* Get the list of file names. */
- ret = __os_dirlist(dbenv, dir, &names, &fcnt);
+ if ((ret = __os_dirlist(dbenv, dir, &names, &fcnt)) != 0)
+ __db_err(dbenv, "%s: %s", dir, db_strerror(ret));
/* Restore the path, and free it. */
*p = saved_byte;
- __os_freestr(path);
+ __os_free(dbenv, path);
- if (ret != 0) {
- __db_err(dbenv, "%s: %s", dir, db_strerror(ret));
+ if (ret != 0)
return (ret);
- }
/*
* Search for valid region names, and remove them. We remove the
@@ -799,19 +821,23 @@ __db_e_remfile(dbenv)
continue;
if (__db_appname(dbenv,
- DB_APP_NONE, NULL, names[cnt], 0, NULL, &path) == 0) {
+ DB_APP_NONE, names[cnt], 0, NULL, &path) == 0) {
+ if (F_ISSET(dbenv, DB_ENV_OVERWRITE))
+ (void)__db_overwrite(dbenv, path);
(void)__os_unlink(dbenv, path);
- __os_freestr(path);
+ __os_free(dbenv, path);
}
}
if (lastrm != -1)
if (__db_appname(dbenv,
- DB_APP_NONE, NULL, names[lastrm], 0, NULL, &path) == 0) {
+ DB_APP_NONE, names[lastrm], 0, NULL, &path) == 0) {
+ if (F_ISSET(dbenv, DB_ENV_OVERWRITE))
+ (void)__db_overwrite(dbenv, path);
(void)__os_unlink(dbenv, path);
- __os_freestr(path);
+ __os_free(dbenv, path);
}
- __os_dirfree(names, fcnt);
+ __os_dirfree(dbenv, names, fcnt);
/*
* !!!
@@ -820,9 +846,9 @@ __db_e_remfile(dbenv)
*/
for (names = (char **)old_region_names; *names != NULL; ++names)
if (__db_appname(dbenv,
- DB_APP_NONE, NULL, *names, 0, NULL, &path) == 0) {
+ DB_APP_NONE, *names, 0, NULL, &path) == 0) {
(void)__os_unlink(dbenv, path);
- __os_freestr(path);
+ __os_free(dbenv, path);
}
return (0);
@@ -832,33 +858,47 @@ __db_e_remfile(dbenv)
* __db_e_stat
* Statistics for the environment.
*
- * PUBLIC: int __db_e_stat __P((DB_ENV *, REGENV *, REGION *, int *));
+ * PUBLIC: int __db_e_stat __P((DB_ENV *,
+ * PUBLIC: REGENV *, REGION *, int *, u_int32_t));
*/
int
-__db_e_stat(dbenv, arg_renv, arg_regions, arg_regions_cnt)
+__db_e_stat(dbenv, arg_renv, arg_regions, arg_regions_cnt, flags)
DB_ENV *dbenv;
REGENV *arg_renv;
REGION *arg_regions;
int *arg_regions_cnt;
+ u_int32_t flags;
{
REGENV *renv;
REGINFO *infop;
REGION *rp;
- int n;
+ int n, ret;
infop = dbenv->reginfo;
renv = infop->primary;
rp = infop->rp;
+ if ((ret = __db_fchk(dbenv,
+ "DB_ENV->stat", flags, DB_STAT_CLEAR)) != 0)
+ return (ret);
/* Lock the environment. */
- MUTEX_LOCK(dbenv, &rp->mutex, dbenv->lockfhp);
+ MUTEX_LOCK(dbenv, &rp->mutex);
*arg_renv = *renv;
+ if (LF_ISSET(DB_STAT_CLEAR)) {
+ renv->mutex.mutex_set_nowait = 0;
+ renv->mutex.mutex_set_wait = 0;
+ }
for (n = 0, rp = SH_LIST_FIRST(&renv->regionq, __db_region);
n < *arg_regions_cnt && rp != NULL;
- ++n, rp = SH_LIST_NEXT(rp, q, __db_region))
+ ++n, rp = SH_LIST_NEXT(rp, q, __db_region)) {
arg_regions[n] = *rp;
+ if (LF_ISSET(DB_STAT_CLEAR)) {
+ rp->mutex.mutex_set_nowait = 0;
+ rp->mutex.mutex_set_wait = 0;
+ }
+ }
/* Release the lock. */
rp = infop->rp;
@@ -887,12 +927,15 @@ __db_r_attach(dbenv, infop, size)
char buf[sizeof(DB_REGION_FMT) + 20];
renv = ((REGINFO *)dbenv->reginfo)->primary;
- F_CLR(infop, REGION_CREATE);
/* Lock the environment. */
- MUTEX_LOCK(dbenv, &renv->mutex, dbenv->lockfhp);
+ MUTEX_LOCK(dbenv, &renv->mutex);
- /* Find or create a REGION structure for this region. */
+ /*
+ * Find or create a REGION structure for this region. If we create
+ * it, the REGION_CREATE flag will be set in the infop structure.
+ */
+ F_CLR(infop, REGION_CREATE);
if ((ret = __db_des_get(dbenv, dbenv->reginfo, infop, &rp)) != 0) {
MUTEX_UNLOCK(dbenv, &renv->mutex);
return (ret);
@@ -903,12 +946,12 @@ __db_r_attach(dbenv, infop, size)
/* If we're creating the region, set the desired size. */
if (F_ISSET(infop, REGION_CREATE))
- rp->size = size;
+ rp->size = (roff_t)size;
/* Join/create the underlying region. */
(void)snprintf(buf, sizeof(buf), DB_REGION_FMT, infop->id);
if ((ret = __db_appname(dbenv,
- DB_APP_NONE, NULL, buf, 0, NULL, &infop->name)) != 0)
+ DB_APP_NONE, buf, 0, NULL, &infop->name)) != 0)
goto err;
if ((ret = __os_r_attach(dbenv, infop, rp)) != 0)
goto err;
@@ -918,8 +961,8 @@ __db_r_attach(dbenv, infop, size)
* anything because we're writing pages in created regions, not just
* reading them.
*/
- (void)__db_faultmem(infop->addr,
- rp->size, F_ISSET(infop, REGION_CREATE));
+ (void)__db_faultmem(dbenv,
+ infop->addr, rp->size, F_ISSET(infop, REGION_CREATE));
/*
* !!!
@@ -940,7 +983,7 @@ __db_r_attach(dbenv, infop, size)
* for it and release our lock on the environment.
*/
if (infop->type != REGION_TYPE_ENV) {
- MUTEX_LOCK(dbenv, &rp->mutex, dbenv->lockfhp);
+ MUTEX_LOCK(dbenv, &rp->mutex);
MUTEX_UNLOCK(dbenv, &renv->mutex);
}
@@ -954,8 +997,10 @@ err: if (infop->addr != NULL)
infop->id = INVALID_REGION_ID;
/* Discard the REGION structure if we created it. */
- if (F_ISSET(infop, REGION_CREATE))
+ if (F_ISSET(infop, REGION_CREATE)) {
(void)__db_des_destroy(dbenv, rp);
+ F_CLR(infop, REGION_CREATE);
+ }
/* Release the environment lock. */
MUTEX_UNLOCK(dbenv, &renv->mutex);
@@ -981,12 +1026,14 @@ __db_r_detach(dbenv, infop, destroy)
renv = ((REGINFO *)dbenv->reginfo)->primary;
rp = infop->rp;
+ if (F_ISSET(dbenv, DB_ENV_PRIVATE))
+ destroy = 1;
/* Lock the environment. */
- MUTEX_LOCK(dbenv, &renv->mutex, dbenv->lockfhp);
+ MUTEX_LOCK(dbenv, &renv->mutex);
/* Acquire the lock for the REGION. */
- MUTEX_LOCK(dbenv, &rp->mutex, dbenv->lockfhp);
+ MUTEX_LOCK(dbenv, &rp->mutex);
/*
* We need to call destroy on per-subsystem info before
@@ -1011,7 +1058,7 @@ __db_r_detach(dbenv, infop, destroy)
/* Destroy the structure. */
if (infop->name != NULL)
- __os_freestr(infop->name);
+ __os_free(dbenv, infop->name);
return (ret);
}
@@ -1089,9 +1136,8 @@ __db_des_get(dbenv, env_infop, infop, rpp)
/* Initialize the region. */
memset(rp, 0, sizeof(*rp));
- if ((ret = __db_mutex_init(dbenv, &rp->mutex,
- R_OFFSET(env_infop, &rp->mutex) + DB_FCNTL_OFF_GEN,
- 0)) != 0) {
+ if ((ret = __db_mutex_setup(dbenv, env_infop, &rp->mutex,
+ MUTEX_NO_RECORD | MUTEX_NO_RLOCK)) != 0) {
__db_shalloc_free(env_infop->addr, rp);
return (ret);
}
@@ -1141,7 +1187,8 @@ __db_des_destroy(dbenv, rp)
* Fault the region into memory.
*/
static int
-__db_faultmem(addr, size, created)
+__db_faultmem(dbenv, addr, size, created)
+ DB_ENV *dbenv;
void *addr;
size_t size;
int created;
@@ -1162,7 +1209,7 @@ __db_faultmem(addr, size, created)
* that it doesn't figure out that we're never really using it.
*/
ret = 0;
- if (DB_GLOBAL(db_region_init)) {
+ if (F_ISSET(dbenv, DB_ENV_REGION_INIT)) {
if (created)
for (p = addr, t = (u_int8_t *)addr + size;
p < t; p += OS_VMPAGESIZE)
@@ -1190,13 +1237,17 @@ __db_region_destroy(dbenv, infop)
case REGION_TYPE_LOCK:
__lock_region_destroy(dbenv, infop);
break;
+ case REGION_TYPE_LOG:
+ __log_region_destroy(dbenv, infop);
+ break;
case REGION_TYPE_MPOOL:
__mpool_region_destroy(dbenv, infop);
break;
+ case REGION_TYPE_TXN:
+ __txn_region_destroy(dbenv, infop);
+ break;
case REGION_TYPE_ENV:
- case REGION_TYPE_LOG:
case REGION_TYPE_MUTEX:
- case REGION_TYPE_TXN:
break;
default:
DB_ASSERT(0);