A mod_db4 Apache module is included in the Berkeley DB distribution, providing a safe framework for running Berkeley DB applications in an Apache 1.3 environment. Apache natively provides no interface for communication between threads or processes, so the mod_db4 module exists to provide this communication.
In general, it is dangerous to run Berkeley DB in a multiprocess system without some facility to coordinate database recovery between processes sharing the database environment after application or system failure. Failure to run recovery after failure can include process hangs and an inability to access the database environment. The mod_db4 Apache module oversees the proper management of Berkeley DB database environment resources. Developers building applications using Berkeley DB as the storage manager within an Apache module should employ this technique for proper resource management.
Specifically, mod_db4 provides the following facilities:
mod_db4 is designed to be used as an alternative interface to Berkeley DB. To have another Apache module (for example, mod_foo) use mod_db4, do not link mod_foo against the Berkeley DB library. In your mod_foo makefile, you should:
and add your Apache include directory to your CPPFLAGS.
In mod_foo, to create a mod_db4 managed DB_ENV handle, use the following:
int mod_db4_db_env_create(DB_ENV **dbenvp, u_int32_t flags);
which takes identical arguments to db_env_create.
To create a mod_db4 managed DB handle, use the following:
int mod_db4_db_create(DB **dbp, DB_ENV *dbenv, u_int32_t flags);
which takes identical arguments to db_create.
Otherwise the API is completely consistent with the standard Sleepycat API.
The mod_db4 module requires the Berkeley DB library be compiled with C++ extensions and the libmm library. Information and source code for the libmm library can be found at http://www.ossp.org/pkg/lib/mm/
To build this apache module, perform the following steps:
% ./configure --with-apxs=[path to the apxs utility] \ --with-db4=[Berkeley DB library installation directory] \ --with-mm=[libmm installation directory] % make % make install
Post-installation, modules can use this extension via the functions documented in $APACHE_INCLUDEDIR/mod_db4_export.h.
Copyright (c) 1996-2005 Sleepycat Software, Inc. - All rights reserved.