• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/db-4.8.30/docs/programmer_reference/
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4  <head>
5    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6    <title>Chapter��21.�� Berkeley DB Extensions</title>
7    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
8    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9    <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
10    <link rel="up" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
11    <link rel="prev" href="tcl_faq.html" title="Tcl FAQ" />
12    <link rel="next" href="ext_perl.html" title="Using Berkeley DB with Perl" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Chapter��21.��
19		Berkeley DB Extensions
20        </th>
21        </tr>
22        <tr>
23          <td width="20%" align="left"><a accesskey="p" href="tcl_faq.html">Prev</a>��</td>
24          <th width="60%" align="center">��</th>
25          <td width="20%" align="right">��<a accesskey="n" href="ext_perl.html">Next</a></td>
26        </tr>
27      </table>
28      <hr />
29    </div>
30    <div class="chapter" lang="en" xml:lang="en">
31      <div class="titlepage">
32        <div>
33          <div>
34            <h2 class="title"><a id="ext"></a>Chapter��21.��
35		Berkeley DB Extensions
36        </h2>
37          </div>
38        </div>
39      </div>
40      <div class="toc">
41        <p>
42          <b>Table of Contents</b>
43        </p>
44        <dl>
45          <dt>
46            <span class="sect1">
47              <a href="ext.html#ext_mod">Using Berkeley DB with Apache</a>
48            </span>
49          </dt>
50          <dt>
51            <span class="sect1">
52              <a href="ext_perl.html">Using Berkeley DB with Perl</a>
53            </span>
54          </dt>
55          <dt>
56            <span class="sect1">
57              <a href="ext_php.html">Using Berkeley DB with PHP</a>
58            </span>
59          </dt>
60        </dl>
61      </div>
62      <div class="sect1" lang="en" xml:lang="en">
63        <div class="titlepage">
64          <div>
65            <div>
66              <h2 class="title" style="clear: both"><a id="ext_mod"></a>Using Berkeley DB with Apache</h2>
67            </div>
68          </div>
69        </div>
70        <p>A mod_db4 Apache module is included in the Berkeley DB distribution, providing
71a safe framework for running Berkeley DB applications in an Apache 1.3
72environment.  Apache natively provides no interface for communication
73between threads or processes, so the mod_db4 module exists to provide
74this communication.</p>
75        <p>In general, it is dangerous to run Berkeley DB in a multiprocess system
76without some facility to coordinate database recovery between processes
77sharing the database environment after application or system failure.
78Failure to run recovery after failure can include process hangs and an
79inability to access the database environment.  The mod_db4 Apache module
80oversees the proper management of Berkeley DB database environment resources.
81Developers building applications using Berkeley DB as the storage manager
82within an Apache module should employ this technique for proper resource
83management.</p>
84        <p>Specifically, mod_db4 provides the following facilities:</p>
85        <div class="orderedlist">
86          <ol type="1">
87            <li>New constructors for <a href="../api_reference/C/env.html" class="olink">DB_ENV</a> and <a href="../api_reference/C/db.html" class="olink">DB</a> handles, which install
88replacement open/close methods.</li>
89            <li>Transparent caching of open <a href="../api_reference/C/env.html" class="olink">DB_ENV</a> and <a href="../api_reference/C/db.html" class="olink">DB</a> handles.</li>
90            <li>Reference counting on all structures, allowing the module to detect the
91initial opening of any managed database and automatically perform recovery.</li>
92            <li>Automatic detection of unexpected failures (segfaults, or a module
93actually calling exit() and avoiding shut down phases), and automatic
94termination of all child processes with open database resources to
95attempt consistency.</li>
96          </ol>
97        </div>
98        <p>mod_db4 is designed to be used as an alternative interface to Berkeley DB.  To
99have another Apache module (for example, mod_foo) use mod_db4, do not
100link mod_foo against the Berkeley DB library.  In your mod_foo makefile, you
101should:</p>
102        <pre class="programlisting">#include "mod_db4_export.h"</pre>
103        <p>and add your Apache include directory to your CPPFLAGS.</p>
104        <p>In mod_foo, to create a mod_db4 managed <a href="../api_reference/C/env.html" class="olink">DB_ENV</a> handle, use the
105following:</p>
106        <pre class="programlisting">int mod_db4_db_env_create(DB_ENV **dbenvp, u_int32_t flags);</pre>
107        <p>which takes identical arguments to <a href="../api_reference/C/envcreate.html" class="olink">db_env_create()</a>.</p>
108        <p>To create a mod_db4 managed <a href="../api_reference/C/db.html" class="olink">DB</a> handle, use the following:</p>
109        <pre class="programlisting">int mod_db4_db_create(DB **dbp, DB_ENV *dbenv, u_int32_t flags);</pre>
110        <p>which takes identical arguments to <a href="../api_reference/C/dbcreate.html" class="olink">db_create()</a>.</p>
111        <p>Otherwise the API is completely consistent with the standard Berkeley DB
112API.</p>
113        <p>The mod_db4 module requires the Berkeley DB library be compiled with C++
114extensions and the MM library.  (The MM library provides an abstraction
115layer which allows related processes to share data easily. On systems
116where shared memory or other inter-process communication mechanisms are
117not available, the MM library emulates them using temporary files. MM
118is used in several operating systems to provide shared memory pools to
119Apache modules.)</p>
120        <p>To build this apache module, perform the following steps:</p>
121        <pre class="programlisting">% ./configure --with-apxs=[path to the apxs utility] \
122	--with-db4=[Berkeley DB library installation directory] \
123	--with-mm=[libmm installation directory]
124% make
125% make install</pre>
126        <p>Post-installation, modules can use this extension via the functions
127documented in $APACHE_INCLUDEDIR/mod_db4_export.h.</p>
128      </div>
129    </div>
130    <div class="navfooter">
131      <hr />
132      <table width="100%" summary="Navigation footer">
133        <tr>
134          <td width="40%" align="left"><a accesskey="p" href="tcl_faq.html">Prev</a>��</td>
135          <td width="20%" align="center">��</td>
136          <td width="40%" align="right">��<a accesskey="n" href="ext_perl.html">Next</a></td>
137        </tr>
138        <tr>
139          <td width="40%" align="left" valign="top">Tcl FAQ��</td>
140          <td width="20%" align="center">
141            <a accesskey="h" href="index.html">Home</a>
142          </td>
143          <td width="40%" align="right" valign="top">��Using Berkeley DB with Perl</td>
144        </tr>
145      </table>
146    </div>
147  </body>
148</html>
149