本文整理汇总了C++中DB_ENV::set_shm_key方法的典型用法代码示例。如果您正苦于以下问题:C++ DB_ENV::set_shm_key方法的具体用法?C++ DB_ENV::set_shm_key怎么用?C++ DB_ENV::set_shm_key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_ENV
的用法示例。
在下文中一共展示了DB_ENV::set_shm_key方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_shm_key
int DbEnv::set_shm_key(long shm_key)
{
int ret;
DB_ENV *dbenv = unwrap(this);
if ((ret = dbenv->set_shm_key(dbenv, shm_key)) != 0)
DB_ERROR("DbEnv::set_shm_key", ret, error_policy());
return (ret);
}
示例2: void
int
cache_init(cache_t *c, void (*freevalue)(void *value))
{
memset(c, '\0', sizeof(*c));
int ret;
DB_ENV *dbenv;
ret = db_env_create(&dbenv, 0);
dbenv->err(dbenv,ret,"err db_env_create ");
dbenv->set_errfile(dbenv, stderr);
dbenv->err(dbenv,ret,"err set_errfile ");
if ((ret = dbenv->set_shm_key(dbenv, 664)) != 0) {
dbenv->err(dbenv,ret,"err set_shm_key ");
return 0;
}
ret = dbenv->open(dbenv,bfile(_temp_path),DB_CREATE | DB_INIT_MPOOL | DB_INIT_CDB ,0);
dbenv->err(dbenv,ret,"err db_env_open ");
/* Create and initialize database object */
if ((ret = db_create(&c->c_data, dbenv, 0)) != 0) {
fprintf(stderr,
"%s: db_create: %s\n", "bbdocument", db_strerror(ret));
return 0;
}
#ifdef DEBUG
dbenv->stat_print(dbenv, DB_STAT_ALL);
#endif
/* open the database. */
if ((ret = c->c_data->open(c->c_data, NULL, "libcachedb", NULL, DB_BTREE, DB_CREATE, 0)) != 0) {
c->c_data->err(c->c_data, ret, "db open");
//goto err1;
//dette skjer nor collection mappen ikke er opprettet enda, typisk forde vi ikke har lagret et dokument der enda
#ifdef DEBUG
printf("can't dbp->open(), but db_create() was sucessful!\n");
#endif
return 0;
}
#ifdef DEBUG
c->c_data->stat_print(c->c_data, DB_STAT_ALL);
#endif
pthread_mutex_init(&c->c_lock, NULL);
c->c_freevalue = freevalue;
return 1;
}
示例3: 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;
}
示例4: sizeof
/*
* This should be done before the program is open for business.
* As such, it does not need to be reentrant.
*/
int
open_db_env(char *topdir)
{
DB_ENV *tmpenv = NULL;
int st;
struct stat64 sbuf;
char logdir[MAXPATHLEN+1];
char tmpdir[MAXPATHLEN+1];
char *dirarr[3];
int i;
if (topdir == NULL) {
return (-1);
}
snprintf(logdir, sizeof (tmpdir), "%s/.logs", topdir);
snprintf(tmpdir, sizeof (tmpdir), "%s/.tmp", topdir);
dirarr[0] = topdir;
dirarr[1] = logdir;
dirarr[2] = tmpdir;
/* first, set up the environment */
st = db_env_create(&tmpenv, 0);
if (st != 0) {
return (st);
}
/* make sure the directories exist */
for (i = 0; i < 3; i++) {
st = stat64(dirarr[i], &sbuf);
if ((st != 0) && (errno == ENOENT)) {
st = mkdirp(dirarr[i], 0744);
if (st == 0) {
st = stat64(dirarr[i], &sbuf);
}
}
if ((st == 0) && (!S_ISDIR(sbuf.st_mode))) {
st = -1;
break;
}
}
if (st != 0) {
return (st);
}
st = tmpenv->set_data_dir(tmpenv, topdir);
if (st != 0) {
return (st);
}
st = tmpenv->set_lg_dir(tmpenv, logdir);
if (st != 0) {
return (st);
}
st = tmpenv->set_tmp_dir(tmpenv, tmpdir);
if (st != 0) {
return (st);
}
st = tmpenv->set_flags(tmpenv, env_fl, 1);
if (st != 0) {
return (st);
}
/* overall database cache size */
st = tmpenv->set_cachesize(tmpenv, 0, (60 * MEGA), 1);
st = tmpenv->set_shm_key(tmpenv, FSM_SHM_MASTER_KEY);
if (st != 0) {
return (st);
}
/* log buffer in memory */
st = tmpenv->set_lg_bsize(tmpenv, (30 * MEGA));
if (st != 0) {
return (st);
}
/* set up additional error logging */
tmpenv->set_errcall(tmpenv, fsmdb_log_err);
/* Increase the number of locks available */
tmpenv->set_lk_max_locks(tmpenv, 10000);
tmpenv->set_lk_max_lockers(tmpenv, 10000);
tmpenv->set_lk_max_objects(tmpenv, 10000);
/* Increase the number of concurrent transactions available */
/* Note: Default in 4.4-20 is '20'. In later versions it's 100 */
tmpenv->set_tx_max(tmpenv, 100);
st = tmpenv->open(tmpenv, topdir, env_ofl, 0644);
if (st != 0) {
/* check for a major failure */
//.........这里部分代码省略.........