# DBENV->close |

`

###

    #include <db.h>

    int
    DBENV->close(DB_ENV *dbenv, u_int32_t flags);

# Description

The DBENV->close function 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 lock_vec call.

Where the environment was initialized with the DB_INIT_MPOOL flag, calling DBENV->close implies calls to memp_fclose for any remaining open files in the memory pool that were returned to this process by calls to memp_fopen. It does not imply a call to memp_fsync 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 function returns a non-zero error value on failure and 0 on success.

# Errors

If a fatal error occurs in Berkeley DB, the DBENV->close function will fail and return DB_RUNRECOVERY, at which point all subsequent database calls will fail in the same way.

In addition, the DBENV->close function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions.

# See Also

DBENV->close, db_env_create, DBENV->open, DBENV->remove, DBENV->err, db_strerror, db_version, DBENV->set_cachesize, DBENV->set_errcall, DBENV->set_errfile, DBENV->set_errpfx, DBENV->set_mutexlocks, DBENV->set_pageyield, DBENV->set_paniccall, DBENV->set_region_init and DBENV->set_verbose.`

Copyright Sleepycat Software