当前位置: 首页>>代码示例>>C++>>正文


C++ DB_ENV::get_open_flags方法代码示例

本文整理汇总了C++中DB_ENV::get_open_flags方法的典型用法代码示例。如果您正苦于以下问题:C++ DB_ENV::get_open_flags方法的具体用法?C++ DB_ENV::get_open_flags怎么用?C++ DB_ENV::get_open_flags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB_ENV的用法示例。


在下文中一共展示了DB_ENV::get_open_flags方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

static uint32_t db_envflags(DB * db)
{
    DB_ENV * env = db->get_env(db);
    uint32_t eflags = 0;
    (void) env->get_open_flags(env, &eflags);
    return eflags;
}
开发者ID:crossbuild,项目名称:rpm,代码行数:7,代码来源:db3.c

示例2: db_fini

static int db_fini(rpmdb rdb, const char * dbhome)
{
    DB_ENV * dbenv = rdb->db_dbenv;
    int rc;
    int lockfd = -1;
    uint32_t eflags = 0;

    if (dbenv == NULL)
	return 0;

    if (rdb->db_opens > 1) {
	rdb->db_opens--;
	return 0;
    }

    (void) dbenv->get_open_flags(dbenv, &eflags);
    if (!(eflags & DB_PRIVATE))
	lockfd = serialize_env(dbhome);

    rc = dbenv->close(dbenv, 0);
    rc = dbapi_err(rdb, "dbenv->close", rc, _debug);

    rpmlog(RPMLOG_DEBUG, "closed   db environment %s\n", dbhome);

    if (!(eflags & DB_PRIVATE) && rdb->db_remove_env) {
	int xx;

	xx = db_env_create(&dbenv, 0);
	xx = dbapi_err(rdb, "db_env_create", xx, _debug);
	xx = dbenv->remove(dbenv, dbhome, 0);
	/* filter out EBUSY as it just means somebody else gets to clean it */
	xx = dbapi_err(rdb, "dbenv->remove", xx, (xx == EBUSY ? 0 : _debug));

	rpmlog(RPMLOG_DEBUG, "removed  db environment %s\n", dbhome);

    }

    if (lockfd >= 0)
	close(lockfd);

    return rc;
}
开发者ID:crossbuild,项目名称:rpm,代码行数:42,代码来源:db3.c

示例3: probe_txn

/** probe if the directory contains an environment, and if so,
 * if it has transactions
 */
e_txn probe_txn(bfpath *bfp)
{
    DB_ENV *dbe;
    int r;
#if DB_AT_LEAST(4,2)
    u_int32_t flags;
#endif

    r = db_env_create(&dbe, 0);
    if (r) {
	print_error(__FILE__, __LINE__, "cannot create environment handle: %s",
		db_strerror(r));
	return T_ERROR;
    }

    /* we might call dbe->set_flags here to set DB_NOPANIC, but this is
     * only supported from 4.1 onwards and probably not worth the
     * effort, we'll just check for DB_RUNRECOVERY */

#if DB_AT_LEAST(3,2)
    r = dbe->open(dbe, bfp->dirname, DB_JOINENV, DS_MODE);
#else
    r = ENOENT;
#endif
    if (r == DB_RUNRECOVERY) {
	dbe->close(dbe, 0);
	return T_ENABLED;
    }

    if (r == ENOENT) {
	struct stat st;
	int w;
	char *t = bfp->filepath;
	struct dirent *de;
	e_txn rc = T_DONT_KNOW;
	DIR *d;

	/* no environment found by JOINENV, but clean up handle */
	dbe->close(dbe, 0);

	/* retry, looking for log\.[0-9]{10} files - needed for instance
	 * after bogoutil --db-remove DIR or when DB_JOINENV is
	 * unsupported */
	d = opendir(bfp->dirname);
	if (d == NULL) {
	    print_error(__FILE__, __LINE__, "cannot open directory %s: %s",
		    t, strerror(r));
	    rc = T_ERROR;
	} else {
	    while ((errno = 0, de = readdir(d))) {
		if (strlen(de->d_name) == 14
		    && strncmp(de->d_name, "log.", 4) == 0
		    && strspn(de->d_name + 4, "0123456789") == 10)
		{
		    rc = T_ENABLED;
		    break;
		}
	    }
	    if (errno)
		rc = T_ERROR;
	    closedir(d);

	    if (rc != T_ERROR && rc != T_ENABLED) {
		w = stat(t, &st);
		if (w == 0) {
		    rc = T_DISABLED;
		} else if (errno != ENOENT) {
		    rc = T_ERROR;
		    print_error(__FILE__, __LINE__, "cannot stat %s: %s",
			    t, db_strerror(r));
		}
	    }
	}
	return rc;
    } /* if (r == ENOENT) for environment join */

    if (r != 0) {
	print_error(__FILE__, __LINE__, "cannot join environment: %s",
		db_strerror(r));
	return T_ERROR;
    }

    /* environment found, validate if it has transactions */
#if DB_AT_LEAST(4,2)
    r = dbe->get_open_flags(dbe, &flags);
    if (r) {
	print_error(__FILE__, __LINE__, "cannot query flags: %s",
		db_strerror(r));
	return T_ERROR;
    }

    dbe->close(dbe, 0);
    if ((flags & DB_INIT_TXN) == 0) {
	print_error(__FILE__, __LINE__,
		"environment found but does not support transactions.");
	return T_ERROR;
    }
//.........这里部分代码省略.........
开发者ID:BenediktGitGit,项目名称:itprojektEFT,代码行数:101,代码来源:datastore_db_trans.c

示例4: main


//.........这里部分代码省略.........
        if (!dbPrivate) {
            dbenv->set_lk_detect(dbenv, DB_LOCK_DEFAULT);
            if (verbose && !envCreate) {
                cout <<
                     "Attempting to join environment: "
                     << (path2DbEnv ? path2DbEnv : ".")
                     << endl;
            }
            dberr = dbenv->open(dbenv, path2DbEnv, DB_USE_ENVIRON, 0);
            if (dberr != 0) {
                if (dberr == DB_VERSION_MISMATCH) {
                    cerr << "Error opening environment "
                         << (path2DbEnv ? path2DbEnv : ".")
                         << ": " << "environment version mismatch" << endl;
                    exit(-1);
                }
                if (verbose) {
                    if(envCreate) {
                        cerr << "Creating environment: "
                             << (path2DbEnv ? path2DbEnv : ".")
                             << endl;
                    } else {
                        cerr << "Unable to join environment "
                             << (path2DbEnv ? path2DbEnv : ".")
                             << ", creating a DB_PRIVATE environment" << endl;
                    }
                }
                dberr = dbenv->open(dbenv, path2DbEnv,
                                    envFlags, 0);
            } else {
                cout <<	"Joined existing environment"
                     << endl;
                u_int32_t eflags = 0;
                dbenv->get_open_flags(dbenv, &eflags);
                if (eflags & DB_INIT_TXN)
                    transactionMode = true;
                else {
                    if (verbose && (transactionMode == true))
                        cout << "Joined a non-transactional environment, turning off transaction mode" << endl;
                    transactionMode = false;
                }
            }
        } else {
            dberr = dbenv->open(dbenv, path2DbEnv,
                                envFlags, 0);
        }
        if (dberr != 0) {
            cerr << "Error opening environment "
                 << (path2DbEnv ? path2DbEnv : ".")
                 << ", error is " << dberr << endl;
            exit(-1);
        }
        XmlManager db(dbenv, dbxmlFlags|DBXML_ADOPT_DBENV);

        // Create the environment
        Environment env(db, sb);
        env.transactions() = transactionMode;

        // Create the Shell object
        DefaultShell shell;

        // Run scripts, if specified
        if(!scripts.empty()) {
            env.interactive() = false;
            env.verbose() = (verbose != 0);
开发者ID:kanbang,项目名称:Colt,代码行数:66,代码来源:dbxmlsh.cpp


注:本文中的DB_ENV::get_open_flags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。