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


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

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


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

示例1: nbsp_open_dbenv

int nbsp_open_dbenv(void){

  DB_ENV *dbenv = NULL;
  int status = 0;
  uint32_t mb;
  uint32_t dbenv_flags = DBENV_FLAGS;

  mb = (1024 * 1024) * g.dbcache_mb;

  status = db_env_create(&dbenv, 0);

  if(status == 0)
    status = dbenv->set_cachesize(dbenv, 0, mb, 0);

  if(status == 0)
    status = dbenv->open(dbenv, g.dbhome, dbenv_flags, g.dbfile_mode);

  if(status != 0){
    log_errx("Cannot initialize db environment. %s", db_strerror(status));
    status = -1;
    if(dbenv != NULL)
      (void)dbenv->close(dbenv, 0);
  }else
    g.dbenv = dbenv;

  return(status);
}
开发者ID:Adnan-Polewall,项目名称:nbsp,代码行数:27,代码来源:dbenv.c

示例2: assert

static void
cleanup()
{
    int rc;
    DB *db;
    DB_ENV *dbenv;
    rc = get_db(&db, 0);
    assert(! rc);
    rc = get_dbenv(&dbenv, 0);
    assert(! rc);
    if (dbkey.data)
	free(dbkey.data);
    if (db)
	call_db(db->close(db, 0), "DB close");
    if (dbenv) {
	rc = call_db(db_create(&db, dbenv, 0), "db_create");
	if (!rc)
	    if (! db->remove(db, "tls_stats.db", 0, 0))
		syslog(LOG_NOTICE, "Unused database tls_stats.db removed");
	call_db(dbenv->txn_checkpoint(dbenv, 100 * 1024, 24 * 60, 0),
		"txn_checkpoint");
	call_db(dbenv->log_archive(dbenv, NULL, DB_ARCH_REMOVE), "log_archive");
	call_db(dbenv->close(dbenv, 0), "DB_ENV close");
    }
    policy_cleanup();
}
开发者ID:dtaht,项目名称:Cryptolisting,代码行数:26,代码来源:cryptolist.c

示例3: dblayer_copy_file_resetlsns

int dblayer_copy_file_resetlsns(char *home_dir ,char *source_file_name, char *destination_file_name, int overwrite, dblayer_private *priv)
{
	int retval = 0;
	DB_ENV *env = NULL;

	LDAPDebug( LDAP_DEBUG_TRACE, "=> dblayer_copy_file_resetlsns\n", 0, 0, 0 );
	/* Make the environment */

	retval = dblayer_make_private_simple_env(home_dir,&env);
	if (retval || !env) {
		LDAPDebug(LDAP_DEBUG_ANY, "dblayer_copy_file_resetlsns: Call to dblayer_make_private_simple_env failed!\n" 
			"Unable to open an environment.", 0, 0, 0);
		goto out;
	}
	/* Do the copy */
	retval = dblayer_copy_file_keybykey(env, source_file_name, destination_file_name, overwrite, priv);
	if (retval) {
		LDAPDebug(LDAP_DEBUG_ANY, "dblayer_copy_file_resetlsns: Copy not completed successfully.", 0, 0, 0);
	}
out:
	/* Close the environment */
	if (env) {
		int retval2 = 0;
		retval2 = env->close(env,0);
		if (retval2) {
			if (0 == retval) {
				retval = retval2;
				LDAPDebug(LDAP_DEBUG_ANY, "dblayer_copy_file_resetlsns, error %d: %s\n", retval, db_strerror(retval), 0);
			}
		}
	}

	LDAPDebug( LDAP_DEBUG_TRACE, "<= dblayer_copy_file_resetlsns\n", 0, 0, 0 );
	return retval;
}
开发者ID:leto,项目名称:389-ds,代码行数:35,代码来源:dbhelp.c

示例4: assert

/*
 * Removes the backend database.  This function shall be called only when
 * nothing holds the database open.
 *
 * 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.
 */
RegStatus
beRemove(
    const char* const   path)
{
    RegStatus   status;
    DB_ENV*     env;

    assert(NULL != path);

    /*
     * First, remove the database.
     */
    if (0 == (status = openEnvironment(path, &env))) {
        if (status = env->dbremove(env, NULL, DB_FILENAME, NULL, 0)) {
            log_add("Couldn't remove database file \"%s\" in \"%s\"",
                    DB_FILENAME, path);
            status = EIO;
        }

        (void)env->close(env, 0);
    }                                   /* "env" allocated */

    /*
     * Then, remove the database environment.
     */
    if (0 == status)
        status = removeEnvironment(path);

    return status;
}
开发者ID:snowlionsun,项目名称:LDM,代码行数:42,代码来源:backend-bdb.c

示例5: TestSetThreadCount

int TestSetThreadCount(CuTest *ct) { /* SKIP */
/* Run this test only when hash is supported. */
#ifdef HAVE_HASH
	DB_ENV *dbenv;
	DB *db;

	CuAssert(ct, "db_env_create", db_env_create(&dbenv, 0) == 0);

	dbenv->set_errpfx(dbenv, "TestSetThreadCount");
	CuAssert(ct, "set_thread_count", dbenv->set_thread_count(dbenv, 2) == 0);
	CuAssert(ct, "env->open", dbenv->open(dbenv, ".",
			DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL |
			DB_INIT_TXN | DB_PRIVATE | DB_THREAD, 0) == 0);

	CuAssert(ct, "db_create", db_create(&db, dbenv, 0) == 0);
	CuAssert(ct, "DB->open", db->open(
	    db, NULL, NULL, "TestSetThreadCount", DB_HASH, DB_CREATE, 0) == 0);

	db->close(db, 0);
	dbenv->close(dbenv, 0);
#else
	printf("TestSetThreadCount is not supported by the build.\n");
#endif /* HAVE_HASH */
	return (0);
}
开发者ID:Pakrik,项目名称:libdb,代码行数:25,代码来源:TestEnvMethod.c

示例6: db_fini

static int db_fini(dbiIndex dbi, const char * dbhome,
		const char * dbfile,
		const char * dbsubfile)
{
    rpmdb rpmdb = dbi->dbi_rpmdb;
    DB_ENV * dbenv = rpmdb->db_dbenv;
    int rc;

    if (dbenv == NULL)
	return 0;

    rc = dbenv->close(dbenv, 0);
    rc = cvtdberr(dbi, "dbenv->close", rc, _debug);

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

    if (rpmdb->db_remove_env) {
	int xx;

	xx = db_env_create(&dbenv, 0);
	xx = cvtdberr(dbi, "db_env_create", xx, _debug);
	xx = dbenv->remove(dbenv, dbhome, 0);
	xx = cvtdberr(dbi, "dbenv->remove", xx, _debug);

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

    }
    return rc;
}
开发者ID:xrg,项目名称:RPM,代码行数:33,代码来源:db3.c

示例7:

DB_ENV *ldbm_initialize_env(const char *home, int dbcachesize, int *envdirok)
{
	DB_ENV *env = NULL;    
	int     err;
	u_int32_t	envFlags;

	err = db_env_create( &env, 0 );

	if ( err ) {
#ifdef LDAP_SYSLOG
		syslog( LOG_INFO, "ldbm_initialize_env(): "
			"FATAL error in db_env_create() : %s (%d)\n",
			db_strerror( err ), err );
#endif
		return NULL;
	}

#if DB_VERSION_X >= 0x030300
	/* This interface appeared in 3.3 */
	env->set_alloc( env, ldbm_malloc, NULL, NULL );
#endif

	env->set_errcall( env, ldbm_db_errcall );
	env->set_errpfx( env, "==>" );
	if (dbcachesize) {
		env->set_cachesize( env, 0, dbcachesize, 0 );
	}

	envFlags = DB_CREATE | DB_INIT_MPOOL | DB_USE_ENVIRON;
#ifdef DB_PRIVATE
	envFlags |= DB_PRIVATE;
#endif
#ifdef DB_MPOOL_PRIVATE
	envFlags |= DB_MPOOL_PRIVATE;
#endif
#ifdef HAVE_BERKELEY_DB_THREAD
	envFlags |= DB_THREAD;
#endif

#if DB_VERSION_X >= 0x030100
	err = env->open( env, home, envFlags, 0 );
#else
	/* 3.0.x requires an extra argument */
	err = env->open( env, home, NULL, envFlags, 0 );
#endif

	if ( err != 0 ) {
#ifdef LDAP_SYSLOG
		syslog(	LOG_INFO, "ldbm_initialize_env(): "
			"FATAL error in dbEnv->open() : %s (%d)\n",
			db_strerror( err ), err );
#endif
		env->close( env, 0 );
		return NULL;
	}

	*envdirok = 1;
	return env;
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:59,代码来源:ldbm.c

示例8: unwrap

// If the DB_ENV handle is still open, we close it.  This is to make stack
// allocation of DbEnv objects easier so that they are cleaned up in the error
// path.  Note that the C layer catches cases where handles are open in the
// environment at close time and reports an error.  Applications should call
// close explicitly in normal (non-exceptional) cases to check the return
// value.
//
DbEnv::~DbEnv()
{
	DB_ENV *env = unwrap(this);

	if (env != NULL) {
		(void)env->close(env, 0);
		cleanup();
	}
}
开发者ID:HackLinux,项目名称:chandler,代码行数:16,代码来源:cxx_env.cpp

示例9: bdblib_create_dbenv

int bdblib_create_dbenv(DB_ENV **_dbenv, char* _home)
{
	DB_ENV *env;
	char *progname;
	int rc, flags;
	
	progname = "kamailio";
	
	/* Create an environment and initialize it for additional error * reporting. */ 
	if ((rc = db_env_create(&env, 0)) != 0) 
	{
		ERR("db_env_create failed! bdb error: %s.\n", db_strerror(rc)); 
		return (rc);
	}
 
	env->set_errpfx(env, progname);

	/*  Specify the shared memory buffer pool cachesize */ 
	if ((rc = env->set_cachesize(env, 0, _bdb_parms->cache_size, 0)) != 0) 
	{
		ERR("dbenv set_cachsize failed! bdb error: %s.\n", db_strerror(rc));
		env->err(env, rc, "set_cachesize"); 
		goto err; 
	}

	/* Concurrent Data Store flags */
	flags = DB_CREATE |
		DB_INIT_CDB |
		DB_INIT_MPOOL |
		DB_THREAD;
	
	/* Transaction Data Store flags ; not supported yet */
	/*
	flags = DB_CREATE |
		DB_RECOVER |
		DB_INIT_LOG | 
		DB_INIT_LOCK |
		DB_INIT_MPOOL |
		DB_THREAD |
		DB_INIT_TXN;
	*/
	
	/* Open the environment */ 
	if ((rc = env->open(env, _home, flags, 0)) != 0) 
	{ 
		ERR("dbenv is not initialized! bdb error: %s.\n",db_strerror(rc));
		env->err(env, rc, "environment open: %s", _home); 
		goto err; 
	}
	
	*_dbenv = env;
	return (0);

err: (void)env->close(env, 0);
	return (rc);
}
开发者ID:SibghatullahSheikh,项目名称:kamailio,代码行数:56,代码来源:bdb_lib.c

示例10: unwrap

// Note: if the user has not closed, we call _destroy_check
// to warn against this non-safe programming practice,
// and call close anyway.
//
DbEnv::~DbEnv()
{
	DB_ENV *env = unwrap(this);

	if (env != NULL) {
		_destroy_check("DbEnv", 1);
		(void)env->close(env, 0);

		// extra safety
		cleanup();
	}
}
开发者ID:NickeyWoo,项目名称:mysql-3.23.49,代码行数:16,代码来源:cxx_app.cpp

示例11: main

int main(int argc,char * argv[])
{
	int rc;
	DB_ENV *env;
	DB *dbi;
	DBT key, data;
	DB_TXN *txn;
	DBC *cursor;
	char sval[32], kval[32];

#define FLAGS (DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_TXN|DB_INIT_MPOOL|DB_CREATE|DB_THREAD)
	rc = db_env_create(&env, 0);
	rc = env->open(env, "./testdb", FLAGS, 0664);
	rc = db_create(&dbi, env, 0);
	rc = env->txn_begin(env, NULL, &txn, 0);
	rc = dbi->open(dbi, txn, "test.bdb", NULL, DB_BTREE, DB_CREATE, 0664);

	memset(&key, 0, sizeof(DBT));
	memset(&data, 0, sizeof(DBT));
	key.size = sizeof(int);
	key.data = sval;
	data.size = sizeof(sval);
	data.data = sval;

	sprintf(sval, "%03x %d foo bar", 32, 3141592);
	rc = dbi->put(dbi, txn, &key, &data, 0);
	rc = txn->commit(txn, 0);
	if (rc) {
		fprintf(stderr, "txn->commit: (%d) %s\n", rc, db_strerror(rc));
		goto leave;
	}
	rc = env->txn_begin(env, NULL, &txn, 0);
	rc = dbi->cursor(dbi, txn, &cursor, 0);
	key.flags = DB_DBT_USERMEM;
	key.data = kval;
	key.ulen = sizeof(kval);
	data.flags = DB_DBT_USERMEM;
	data.data = sval;
	data.ulen = sizeof(sval);
	while ((rc = cursor->c_get(cursor, &key, &data, DB_NEXT)) == 0) {
		printf("key: %p %.*s, data: %p %.*s\n",
			key.data,  (int) key.size,  (char *) key.data,
			data.data, (int) data.size, (char *) data.data);
	}
	rc = cursor->c_close(cursor);
	rc = txn->abort(txn);
leave:
	rc = dbi->close(dbi, 0);
	rc = env->close(env, 0);
	return rc;
}
开发者ID:AUSTRALIANBITCOINS,项目名称:rippled,代码行数:51,代码来源:sample-bdb.c

示例12: fprintf

void
env_open(DB_ENV **dbenvp)
{
        DB_ENV *dbenv;
        int ret;




        /* Create the environment handle. */
        if ((ret = db_env_create(&dbenv, 0)) != 0) {
                fprintf(stderr,
                    "txnapp: db_env_create: %s\n", db_strerror(ret));
                exit (1);
        }




        /* Set up error handling. */
        dbenv->set_errpfx(dbenv, "txnapp");
        dbenv->set_errfile(dbenv, stderr);




        /*
         * Open a transactional environment:
         *      create if it doesn't exist
         *      free-threaded handle
         *      run recovery
         *      read/write owner only
         */
        if ((ret = dbenv->open(dbenv, ENV_DIRECTORY,
            DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG |
            DB_INIT_MPOOL | DB_INIT_TXN | DB_RECOVER ,
            S_IRUSR | S_IWUSR)) != 0) {
                (void)dbenv->close(dbenv, 0);
                fprintf(stderr, "dbenv->open: %s: %s\n",
                    ENV_DIRECTORY, db_strerror(ret));
                exit (1);
        }




        *dbenvp = dbenv;
}
开发者ID:Zhoutall,项目名称:stasis,代码行数:48,代码来源:jbhashmany.c

示例13: while

int
main(int argc, char *argv[])
{
    extern char *optarg;
    DB_ENV *dbenv;
    const char *home;
    char ch;
    int ret;

    dbenv = NULL;

    ret = 0;
    home = NULL;

    /* Create and configure the environment handle. */
    if ((ret = create_env(progname, &dbenv)) != 0)
	goto err;

    /* Collect the command line options. */
    while ((ch = getopt(argc, argv, "h:")) != EOF)
	switch (ch) {
	case 'h':
	    home = optarg;
	    break;
	case '?':
	default:
	    usage();
	}

    /* Error check command line. */
    if (home == NULL)
	usage();

    /* Open the environment. */
    if ((ret = env_init(dbenv, home)) != 0)
      goto err;

    if ((ret = doloop(dbenv)) != 0) {
	dbenv->err(dbenv, ret, "Application failed");
	goto err;
    }

err: if (dbenv != NULL)
	(void)dbenv->close(dbenv, 0);

    return (ret);
}
开发者ID:kanbang,项目名称:Colt,代码行数:47,代码来源:simple_txn.c

示例14: unwrap

// If the DB_ENV handle is still open, we close it.  This is to make stack
// allocation of DbEnv objects easier so that they are cleaned up in the error
// path.  Note that the C layer catches cases where handles are open in the
// environment at close time and reports an error.  Applications should call
// close explicitly in normal (non-exceptional) cases to check the return
// value.
//
DbEnv::~DbEnv()
{
	DB_ENV *dbenv = unwrap(this);

	/* 
	 * Specify DB_FORCESYNC to make sure databases are sync'ed to disk.
	 * Users can call DbEnv::close with 0 as real parameter to close all
	 * but the last environment object/handle. Doing so can avoid
	 * unnecessary database syncs. The last environment object/handle
	 * must be closed with DB_FORCESYNC parameter, or be closed via this
	 * function.
	 */
	if (dbenv != NULL) {
		(void)dbenv->close(dbenv, DB_FORCESYNC);
		cleanup();
	}
}
开发者ID:Mayalinux,项目名称:db,代码行数:24,代码来源:cxx_env.cpp

示例15:

void
bdb_close(void)
{
	DB *db;
	DBC *dbc;
	DB_ENV *dbenv;

	dbc = g.dbc;
	db = g.bdb;
	dbenv = db->dbenv;
	assert(dbc->close(dbc) == 0);
	assert(db->close(db, 0) == 0);
	assert(dbenv->close(dbenv, 0) == 0);

	free(keybuf);
	keybuf = NULL;
}
开发者ID:qixin,项目名称:wiredtiger,代码行数:17,代码来源:bdb.c


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