本文整理汇总了C++中DB_ENV::set_verbose方法的典型用法代码示例。如果您正苦于以下问题:C++ DB_ENV::set_verbose方法的具体用法?C++ DB_ENV::set_verbose怎么用?C++ DB_ENV::set_verbose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_ENV
的用法示例。
在下文中一共展示了DB_ENV::set_verbose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: r
int
dbfe_initialize_dbenv (DB_ENV **dbep, str filename, bool join, unsigned int cachesize = 1024)
{
int r (-1);
r = mkdir (filename, 0755);
if (r < 0 && errno != EEXIST) {
fatal ("Couldn't mkdir for database %s: %m", filename.cstr ());
}
r = db_env_create (dbep, 0);
if (r) return r;
DB_ENV *dbe = *dbep;
// Enable verbose dead lock detection.
dbe->set_verbose (dbe, DB_VERB_DEADLOCK, 1);
dbe->set_verbose (dbe, DB_VERB_WAITSFOR, 1);
dbe->set_lk_detect (dbe, DB_LOCK_DEFAULT);
dbe->set_errfile (dbe, stderr);
if (!join) {
// Force the latest parameters
strbuf db_config_path ("%s/DB_CONFIG", filename.cstr ());
dbfe_generate_config (db_config_path, cachesize);
// We use all the fixings
r = dbe->open (dbe, filename, DB_CREATE |
DB_INIT_MPOOL |
DB_INIT_LOCK |
DB_INIT_LOG |
DB_INIT_TXN |
DB_RECOVER , 0);
} else {
r = dbe->open (dbe, filename, DB_JOINENV, 0);
}
return r;
}
示例2: db_init
static int db_init(rpmdb rdb, const char * dbhome)
{
DB_ENV *dbenv = NULL;
int rc, xx;
int retry_open = 2;
int lockfd = -1;
struct dbConfig_s * cfg = &rdb->cfg;
/* This is our setup, thou shall not have other setups before us */
uint32_t eflags = (DB_CREATE|DB_INIT_MPOOL|DB_INIT_CDB);
if (rdb->db_dbenv != NULL) {
rdb->db_opens++;
return 0;
} else {
/* On first call, set backend description to something... */
free(rdb->db_descr);
rasprintf(&rdb->db_descr, "db%u", DB_VERSION_MAJOR);
}
/*
* Both verify and rebuild are rather special, if for different reasons:
* On rebuild we dont want to be affected by eg paniced environment, and
* CDB only slows things down there. Verify is a quirky beast unlike
* anything else in BDB, and does not like shared env or CDB.
*/
if (rdb->db_flags & (RPMDB_FLAG_VERIFYONLY|RPMDB_FLAG_REBUILD)) {
eflags |= DB_PRIVATE;
eflags &= ~DB_INIT_CDB;
}
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;
}
}
//.........这里部分代码省略.........
示例3: rpmGenPath
static int db3close(dbiIndex dbi, unsigned int flags)
{
rpmdb rpmdb = dbi->dbi_rpmdb;
const char * root;
const char * home;
char * dbhome;
const char * dbfile;
const char * dbsubfile;
DB * db = dbi->dbi_db;
int _printit;
int rc = 0, xx;
flags = 0; /* XXX unused */
/*
* Get the prefix/root component and directory path.
*/
root = (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root);
if ((root[0] == '/' && root[1] == '\0') || rpmdb->db_chrootDone)
root = NULL;
home = (dbi->dbi_home ? dbi->dbi_home : rpmdb->db_home);
dbhome = rpmGenPath(root, home, NULL);
if (dbi->dbi_temporary) {
dbfile = NULL;
dbsubfile = NULL;
} else {
#ifdef HACK /* XXX necessary to support dbsubfile */
dbfile = (dbi->dbi_file ? dbi->dbi_file : db3basename);
dbsubfile = (dbi->dbi_subfile ? dbi->dbi_subfile : rpmTagGetName(dbi->dbi_rpmtag));
#else
dbfile = (dbi->dbi_file ? dbi->dbi_file : rpmTagGetName(dbi->dbi_rpmtag));
dbsubfile = NULL;
#endif
}
if (db) {
rc = db->close(db, 0);
/* XXX ignore not found error messages. */
_printit = (rc == ENOENT ? 0 : _debug);
rc = cvtdberr(dbi, "db->close", rc, _printit);
db = dbi->dbi_db = NULL;
rpmlog(RPMLOG_DEBUG, "closed db index %s/%s\n",
dbhome, (dbfile ? dbfile : rpmTagGetName(dbi->dbi_rpmtag)));
}
if (rpmdb->db_dbenv != NULL && dbi->dbi_use_dbenv) {
if (rpmdb->db_opens == 1) {
xx = db_fini(dbi, (dbhome ? dbhome : ""), dbfile, dbsubfile);
rpmdb->db_dbenv = NULL;
}
rpmdb->db_opens--;
}
if (dbi->dbi_verify_on_close && !dbi->dbi_temporary) {
DB_ENV * dbenv = NULL;
rc = db_env_create(&dbenv, 0);
rc = cvtdberr(dbi, "db_env_create", rc, _debug);
if (rc || dbenv == NULL) goto exit;
dbenv->set_errcall(dbenv, (void *) rpmdb->db_errcall);
dbenv->set_errfile(dbenv, rpmdb->db_errfile);
dbenv->set_errpfx(dbenv, rpmdb->db_errpfx);
/* dbenv->set_paniccall(???) */
#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_tmpdir) {
char * tmpdir = rpmGenPath(root, dbi->dbi_tmpdir, NULL);
rc = dbenv->set_tmp_dir(dbenv, tmpdir);
rc = cvtdberr(dbi, "dbenv->set_tmp_dir", rc, _debug);
tmpdir = _free(tmpdir);
if (rc) goto exit;
}
rc = (dbenv->open)(dbenv, dbhome,
DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_USE_ENVIRON, 0);
rc = cvtdberr(dbi, "dbenv->open", rc, _debug);
if (rc) goto exit;
rc = db_create(&db, dbenv, 0);
rc = cvtdberr(dbi, "db_create", rc, _debug);
if (db != NULL) {
char * dbf = rpmGetPath(dbhome, "/", dbfile, NULL);
rc = db->verify(db, dbf, NULL, NULL, flags);
rc = cvtdberr(dbi, "db->verify", rc, _debug);
//.........这里部分代码省略.........
示例4: db_init
static int db_init(dbiIndex dbi, const char * dbhome,
const char * dbfile,
const char * dbsubfile,
DB_ENV ** dbenvp)
{
rpmdb rpmdb = dbi->dbi_rpmdb;
DB_ENV *dbenv = NULL;
int eflags;
int rc;
if (dbenvp == NULL)
return 1;
/* XXX HACK */
if (rpmdb->db_errfile == NULL)
rpmdb->db_errfile = stderr;
eflags = (dbi->dbi_oeflags | dbi->dbi_eflags);
if (eflags & DB_JOINENV) eflags &= DB_JOINENV;
if (dbfile) {
char *dbiflags = prDbiOpenFlags(eflags, 1);
rpmlog(RPMLOG_DEBUG, "opening db environment %s/%s %s\n",
dbhome, dbfile, dbiflags);
free(dbiflags);
}
/* XXX Can't do RPC w/o host. */
if (dbi->dbi_host == NULL)
dbi->dbi_ecflags &= ~DB_CLIENT;
/* XXX Set a default shm_key. */
if ((dbi->dbi_eflags & DB_SYSTEM_MEM) && dbi->dbi_shmkey == 0) {
#if defined(HAVE_FTOK)
dbi->dbi_shmkey = ftok(dbhome, 0);
#else
dbi->dbi_shmkey = 0x44631380;
#endif
}
rc = db_env_create(&dbenv, dbi->dbi_ecflags);
rc = cvtdberr(dbi, "db_env_create", rc, _debug);
if (dbenv == NULL || rc)
goto errxit;
{ int xx;
/* 4.1: dbenv->set_app_dispatch(???) */
/* 4.1: dbenv->set_alloc(???) */
/* 4.1: dbenv->set_data_dir(???) */
/* 4.1: dbenv->set_encrypt(???) */
dbenv->set_errcall(dbenv, (void *) rpmdb->db_errcall);
dbenv->set_errfile(dbenv, rpmdb->db_errfile);
dbenv->set_errpfx(dbenv, rpmdb->db_errpfx);
/* 4.1: dbenv->set_feedback(???) */
/* 4.1: dbenv->set_flags(???) */
/* dbenv->set_paniccall(???) */
#if (DB_VERSION_MAJOR >= 4 && DB_VERSION_MINOR >= 5)
/*
* 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, db3isalive);
#endif
if ((dbi->dbi_ecflags & DB_CLIENT) && dbi->dbi_host) {
const char * home;
int retry = 0;
if ((home = strrchr(dbhome, '/')) != NULL)
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);
//.........这里部分代码省略.........