Berkeley DB: DbEnv::close
Description: Berkeley DB: An embedded database programmatic toolkit.
Keywords: embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++

# DbEnv::close |

`

###

    #include <db_cxx.h>

    DbEnv::close(u_int32_t flags);

# Description

The DbEnv::close method closes the Berkeley DB environment, freeing any allocated resources and closing any underlying subsystems.

Calling DbEnv::close does not imply closing any databases that were opened in the environment.

The flags parameter is currently unused, and must be set to 0.

Where the environment was initialized with the DB_INIT_LOCK flag, calling DbEnv::close does not release any locks still held by the closing process, providing functionality for long-lived locks. Processes that wish to have all their locks released can do so by issuing the appropriate DbEnv::lock_vec call.

Where the environment was initialized with the DB_INIT_MPOOL flag, calling DbEnv::close implies calls to DbMpoolFile::close for any remaining open files in the memory pool that were returned to this process by calls to DbMpoolFile::open. It does not imply a call to DbMpoolFile::sync for those files.

Where the environment was initialized with the DB_INIT_TXN flag, calling DbEnv::close aborts any uncommitted transactions. (Applications are should not depend on this behavior. If the process' has already closed a database handle which is necessary to abort an uncommitted transaction, the Berkeley DB environment must then require that recovery be run before further operations are done, since once a transaction exists that cannot be committed or aborted, no future checkpoint can ever succeed.)

In multi-threaded applications, only a single thread may call DbEnv::close.

Once DbEnv::close has been called, regardless of its return, the Berkeley DB environment handle may not be accessed again.

The DbEnv::close method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

# Errors

The DbEnv::close method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. If a catastrophic error has occurred, the DbEnv::close method may fail and either return DB_RUNRECOVERY or throw an exception encapsulating DB_RUNRECOVERY, in which case all subsequent Berkeley DB calls will fail in the same way.

### Class

DbEnv

# See Also

DbEnv::close, DbEnv::open, DbEnv::remove, DbEnv::err, DbEnv::strerror, DbEnv::version, DbEnv::set_cachesize, DbEnv::set_errcall, DbEnv::set_errfile, DbEnv::set_error_stream, DbEnv::set_errpfx, DbEnv::set_paniccall, and DbEnv::set_verbose.`

Copyright Sleepycat Software