1<!--$Id: env_close.so,v 10.38 2004/08/13 03:38:56 bostic Exp $-->
2<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
3<!--See the file LICENSE for redistribution information.-->
4<html>
5<head>
6<title>Berkeley DB: DB_ENV-&gt;close</title>
7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
9</head>
10<body bgcolor=white>
11<table width="100%"><tr valign=top>
12<td>
13<b>DB_ENV-&gt;close</b>
14</td>
15<td align=right>
16<a href="/api_c/api_core.html"><img src="/images/api.gif" alt="API"></a>
17<a href="/ref/toc.html"><img src="/images/ref.gif" alt="Ref"></a></td>
18</tr></table>
19<hr size=1 noshade>
20<tt>
21<b><pre>
22#include &lt;db.h&gt;
23<p>
24int
25DB_ENV-&gt;close(DB_ENV *dbenv, u_int32_t flags);
26</pre></b>
27<hr size=1 noshade>
28<b>Description: DB_ENV-&gt;close</b>
29<p>The DB_ENV-&gt;close method closes the Berkeley DB environment, freeing any
30allocated resources and closing any underlying subsystems.</p>
31<p>The <a href="/api_c/env_class.html">DB_ENV</a> handle should not be closed while any other handle
32that refers to it is not yet closed; for example, database environment
33handles must not be closed while database handles remain open, or
34transactions in the environment have not yet been committed or aborted.
35Specifically, this includes <a href="/api_c/db_class.html">DB</a>, <a href="/api_c/dbc_class.html">DBC</a>, <a href="/api_c/txn_class.html">DB_TXN</a>,
36<a href="/api_c/logc_class.html">DB_LOGC</a> and <a href="/api_c/mempfile_class.html">DB_MPOOLFILE</a> handles.</p>
37<p>Where the environment was initialized with the <a href="/api_c/env_open.html#DB_INIT_LOCK">DB_INIT_LOCK</a>
38flag, calling DB_ENV-&gt;close does not release any locks still held
39by the closing process, providing functionality for long-lived locks.
40Processes that want to have all their locks released can do so by
41issuing the appropriate <a href="/api_c/lock_vec.html">DB_ENV-&gt;lock_vec</a> call.</p>
42<p>Where the environment was initialized with the <a href="/api_c/env_open.html#DB_INIT_MPOOL">DB_INIT_MPOOL</a>
43flag, calling DB_ENV-&gt;close implies calls to <a href="/api_c/memp_fclose.html">DB_MPOOLFILE-&gt;close</a> for
44any remaining open files in the memory pool that were returned to this
45process by calls to <a href="/api_c/memp_fopen.html">DB_MPOOLFILE-&gt;open</a>.  It does not imply a call to
46<a href="/api_c/memp_fsync.html">DB_MPOOLFILE-&gt;sync</a> for those files.</p>
47<p>Where the environment was initialized with the <a href="/api_c/env_open.html#DB_INIT_TXN">DB_INIT_TXN</a> flag,
48calling DB_ENV-&gt;close aborts any unresolved transactions.
49Applications should not depend on this behavior for transactions
50involving Berkeley DB databases; all such transactions should be explicitly
51resolved.  The problem with depending on this semantic is that aborting
52an unresolved transaction involving database operations requires a
53database handle.  Because the database handles should have been closed before
54calling DB_ENV-&gt;close, it will not be possible to abort the
55transaction, and recovery will have to be run on the Berkeley DB environment
56before further operations are done.</p>
57<p>Where log cursors were created using the <a href="/api_c/log_cursor.html">DB_ENV-&gt;log_cursor</a> method, calling
58DB_ENV-&gt;close does not imply closing those cursors.</p>
59<p>In multithreaded applications, only a single thread may call
60DB_ENV-&gt;close.</p>
61<p>After DB_ENV-&gt;close has been called, regardless of its return, the
62Berkeley DB environment handle may not be accessed again.</p>
63<p>The DB_ENV-&gt;close method
64returns a non-zero error value on failure
65and 0 on success.
66</p>
67<b>Parameters</b> <br>
68 <b>flags</b><ul compact><li>The <b>flags</b> parameter is currently unused, and must be set to 0.</ul>
69<br>
70<hr size=1 noshade>
71<br><b>Class</b>
72<a href="/api_c/env_class.html">DB_ENV</a>
73<br><b>See Also</b>
74<a href="/api_c/env_list.html">Database Environments and Related Methods</a>
75</tt>
76<table width="100%"><tr><td><br></td><td align=right>
77<a href="/api_c/api_core.html"><img src="/images/api.gif" alt="API"></a><a href="/ref/toc.html"><img src="/images/ref.gif" alt="Ref"></a>
78</td></tr></table>
79<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
80</body>
81</html>
82