本文整理汇总了C++中DB_ENV::failchk方法的典型用法代码示例。如果您正苦于以下问题:C++ DB_ENV::failchk方法的具体用法?C++ DB_ENV::failchk怎么用?C++ DB_ENV::failchk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_ENV
的用法示例。
在下文中一共展示了DB_ENV::failchk方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cvtdberr
static dbiCursor db3_dbiCursorInit(dbiIndex dbi, unsigned int flags)
{
dbiCursor dbc = NULL;
if (dbi && dbi->dbi_db) {
DB * db = dbi->dbi_db;
DBC * cursor;
int cflags;
int rc = 0;
uint32_t eflags = db_envflags(db);
/* DB_WRITECURSOR requires CDB and writable db */
if ((flags & DBC_WRITE) &&
(eflags & DB_INIT_CDB) && !(dbi->dbi_flags & DBI_RDONLY))
{
cflags = DB_WRITECURSOR;
} else
cflags = 0;
/*
* Check for stale locks which could block writes "forever".
* XXX: Should we also do this on reads? Reads are less likely
* to get blocked so it seems excessive...
* XXX: On DB_RUNRECOVER, we should abort everything. Now
* we'll just fail to open a cursor again and again and again.
*/
if (cflags & DB_WRITECURSOR) {
DB_ENV *dbenv = db->get_env(db);
rc = dbenv->failchk(dbenv, 0);
rc = cvtdberr(dbi, "dbenv->failchk", rc, _debug);
}
if (rc == 0) {
rc = db->cursor(db, NULL, &cursor, cflags);
rc = cvtdberr(dbi, "db->cursor", rc, _debug);
}
if (rc == 0) {
dbc = xcalloc(1, sizeof(*dbc));
dbc->cursor = cursor;
dbc->dbi = dbi;
dbc->flags = flags;
}
}
return dbc;
}
示例2: assert
/*
* Checks the database environment.
*
* ARGUMENTS:
* path Pathname of the database directory. Shall not be NULL.
* The client can free it upon return.
* RETURNS:
* 0 Success.
* ENOMEM System error. "log_start()" called.
* EIO Backend database error. "log_start()" called.
* ECANCELED The database environment must be recovered.
* "log_start()" called.
*/
static RegStatus
verifyEnvironment(
const char* const path)
{
RegStatus status;
DB_ENV* env;
assert(NULL != path);
if (0 == (status = openEnvironment(path, &env))) {
if (0 != (status = env->failchk(env, 0))) {
log_add("The environment of database \"%s\" must be recovered",
path);
status = ECANCELED;
}
(void)env->close(env, 0);
} /* "env" allocated */
return status;
}
示例3: db_init
//.........这里部分代码省略.........
rc = db_env_create(&dbenv, 0);
rc = dbapi_err(rdb, "db_env_create", rc, _debug);
if (dbenv == NULL || rc)
goto errxit;
dbenv->set_alloc(dbenv, rmalloc, rrealloc, NULL);
dbenv->set_errcall(dbenv, NULL);
dbenv->set_errpfx(dbenv, _errpfx);
dbenv->set_msgcall(dbenv, warnlog);
/*
* These enable automatic stale lock removal.
* thread_count 8 is some kind of "magic minimum" value...
*/
dbenv->set_thread_count(dbenv, 8);
dbenv->set_isalive(dbenv, isalive);
dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK,
(cfg->db_verbose & DB_VERB_DEADLOCK));
dbenv->set_verbose(dbenv, DB_VERB_RECOVERY,
(cfg->db_verbose & DB_VERB_RECOVERY));
dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR,
(cfg->db_verbose & DB_VERB_WAITSFOR));
if (cfg->db_mmapsize) {
xx = dbenv->set_mp_mmapsize(dbenv, cfg->db_mmapsize);
xx = dbapi_err(rdb, "dbenv->set_mp_mmapsize", xx, _debug);
}
if (cfg->db_cachesize) {
xx = dbenv->set_cachesize(dbenv, 0, cfg->db_cachesize, 0);
xx = dbapi_err(rdb, "dbenv->set_cachesize", xx, _debug);
}
/*
* Serialize shared environment open (and clock) via fcntl() lock.
* Otherwise we can end up calling dbenv->failchk() while another
* process is joining the environment, leading to transient
* DB_RUNRECOVER errors. Also prevents races wrt removing the
* environment (eg chrooted operation). Silently fall back to
* private environment on failure to allow non-privileged queries
* to "work", broken as it might be.
*/
if (!(eflags & DB_PRIVATE)) {
lockfd = serialize_env(dbhome);
if (lockfd < 0) {
eflags |= DB_PRIVATE;
retry_open--;
rpmlog(RPMLOG_DEBUG, "serialize failed, using private dbenv\n");
}
}
/*
* Actually open the environment. Fall back to private environment
* if we dont have permission to join/create shared environment or
* system doesn't support it..
*/
while (retry_open) {
char *fstr = prDbiOpenFlags(eflags, 1);
rpmlog(RPMLOG_DEBUG, "opening db environment %s %s\n", dbhome, fstr);
free(fstr);
rc = (dbenv->open)(dbenv, dbhome, eflags, rdb->db_perms);
if ((rc == EACCES || rc == EROFS) || (rc == EINVAL && errno == rc)) {
eflags |= DB_PRIVATE;
retry_open--;
} else {
retry_open = 0;
}
}
rc = dbapi_err(rdb, "dbenv->open", rc, _debug);
if (rc)
goto errxit;
dbenv->set_errcall(dbenv, errlog);
/* stale lock removal */
rc = dbenv->failchk(dbenv, 0);
rc = dbapi_err(rdb, "dbenv->failchk", rc, _debug);
if (rc)
goto errxit;
rdb->db_dbenv = dbenv;
rdb->db_opens = 1;
if (lockfd >= 0)
close(lockfd);
return 0;
errxit:
if (dbenv) {
int xx;
xx = dbenv->close(dbenv, 0);
xx = dbapi_err(rdb, "dbenv->close", xx, _debug);
}
if (lockfd >= 0)
close(lockfd);
return rc;
}
示例4: db_init
//.........这里部分代码省略.........
dbhome = ++home;
while (retry++ < 5) {
xx = dbenv->set_rpc_server(dbenv, NULL, dbi->dbi_host,
dbi->dbi_cl_timeout, dbi->dbi_sv_timeout, 0);
xx = cvtdberr(dbi, "dbenv->set_server", xx, _debug);
if (!xx)
break;
(void) sleep(15);
}
} else {
#if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
xx = dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT,
(dbi->dbi_verbose & DB_VERB_CHKPOINT));
#endif
xx = dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK,
(dbi->dbi_verbose & DB_VERB_DEADLOCK));
xx = dbenv->set_verbose(dbenv, DB_VERB_RECOVERY,
(dbi->dbi_verbose & DB_VERB_RECOVERY));
xx = dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR,
(dbi->dbi_verbose & DB_VERB_WAITSFOR));
if (dbi->dbi_mmapsize) {
xx = dbenv->set_mp_mmapsize(dbenv, dbi->dbi_mmapsize);
xx = cvtdberr(dbi, "dbenv->set_mp_mmapsize", xx, _debug);
}
if (dbi->dbi_tmpdir) {
const char * root;
char * tmpdir;
root = (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root);
if ((root[0] == '/' && root[1] == '\0') || rpmdb->db_chrootDone)
root = NULL;
tmpdir = rpmGenPath(root, dbi->dbi_tmpdir, NULL);
xx = dbenv->set_tmp_dir(dbenv, tmpdir);
xx = cvtdberr(dbi, "dbenv->set_tmp_dir", xx, _debug);
tmpdir = _free(tmpdir);
}
}
/* dbenv->set_lk_conflicts(???) */
/* dbenv->set_lk_detect(???) */
/* 4.1: dbenv->set_lk_max_lockers(???) */
/* 4.1: dbenv->set_lk_max_locks(???) */
/* 4.1: dbenv->set_lk_max_objects(???) */
/* 4.1: dbenv->set_lg_bsize(???) */
/* 4.1: dbenv->set_lg_dir(???) */
/* 4.1: dbenv->set_lg_max(???) */
/* 4.1: dbenv->set_lg_regionmax(???) */
if (dbi->dbi_cachesize) {
xx = dbenv->set_cachesize(dbenv, 0, dbi->dbi_cachesize, 0);
xx = cvtdberr(dbi, "dbenv->set_cachesize", xx, _debug);
}
/* 4.1 dbenv->set_timeout(???) */
/* dbenv->set_tx_max(???) */
/* 4.1: dbenv->set_tx_timestamp(???) */
/* dbenv->set_tx_recover(???) */
/* dbenv->set_rep_transport(???) */
/* dbenv->set_rep_limit(???) */
if (dbi->dbi_no_fsync) {
xx = db_env_set_func_fsync(db3_fsync_disable);
xx = cvtdberr(dbi, "db_env_set_func_fsync", xx, _debug);
}
if (dbi->dbi_shmkey) {
xx = dbenv->set_shm_key(dbenv, dbi->dbi_shmkey);
xx = cvtdberr(dbi, "dbenv->set_shm_key", xx, _debug);
}
}
rc = (dbenv->open)(dbenv, dbhome, eflags, dbi->dbi_perms);
rc = cvtdberr(dbi, "dbenv->open", rc, _debug);
if (rc)
goto errxit;
#if (DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 5)
/* stale lock removal */
rc = dbenv->failchk(dbenv, 0);
rc = cvtdberr(dbi, "dbenv->failchk", rc, _debug);
if (rc)
goto errxit;
#endif
*dbenvp = dbenv;
return 0;
errxit:
if (dbenv) {
int xx;
xx = dbenv->close(dbenv, 0);
xx = cvtdberr(dbi, "dbenv->close", xx, _debug);
}
return rc;
}