Commit 5ae46c19 authored by Ralf Haferkamp's avatar Ralf Haferkamp
Browse files

Added a new parameter (ConfigArgs*) to the _db_init, _db_open, _db_close and

_db_destroy functions.
parent 6a4dd271
......@@ -320,9 +320,9 @@ bdb_cf_cleanup( ConfigArgs *c )
if ( bdb->bi_flags & BDB_RE_OPEN ) {
bdb->bi_flags ^= BDB_RE_OPEN;
rc = c->be->bd_info->bi_db_close( c->be );
rc = c->be->bd_info->bi_db_close( c->be, NULL );
if ( rc == 0 )
rc = c->be->bd_info->bi_db_open( c->be );
rc = c->be->bd_info->bi_db_open( c->be, NULL );
/* If this fails, we need to restart */
if ( rc ) {
slapd_shutdown = 2;
......
......@@ -26,6 +26,7 @@
#include <lutil.h>
#include <ldap_rq.h>
#include "alock.h"
#include "config.h"
static const struct bdbi_database {
char *file;
......@@ -46,7 +47,7 @@ typedef void * db_realloc(void *, size_t);
#define bdb_db_close BDB_SYMBOL(db_close)
static int
bdb_db_init( BackendDB *be )
bdb_db_init( BackendDB *be, ConfigArgs *ca )
{
struct bdb_info *bdb;
int rc;
......@@ -93,10 +94,10 @@ bdb_db_init( BackendDB *be )
}
static int
bdb_db_close( BackendDB *be );
bdb_db_close( BackendDB *be, ConfigArgs *ca );
static int
bdb_db_open( BackendDB *be )
bdb_db_open( BackendDB *be, ConfigArgs *ca )
{
int rc, i;
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
......@@ -121,8 +122,8 @@ bdb_db_open( BackendDB *be )
#ifndef BDB_MULTIPLE_SUFFIXES
if ( be->be_suffix[1].bv_val ) {
Debug( LDAP_DEBUG_ANY,
LDAP_XSTRING(bdb_db_open) ": only one suffix allowed\n", 0, 0, 0 );
Debug( LDAP_DEBUG_ANY,
LDAP_XSTRING(bdb_db_open) ": only one suffix allowed\n", 0, 0, 0 );
return -1;
}
#endif
......@@ -133,7 +134,7 @@ bdb_db_open( BackendDB *be )
Debug( LDAP_DEBUG_ANY,
LDAP_XSTRING(bdb_db_open) ": Cannot access database directory %s (%d)\n",
bdb->bi_dbenv_home, errno, 0 );
return -1;
return -1;
}
/* Perform database use arbitration/recovery logic */
......@@ -474,12 +475,12 @@ shm_retry:
return 0;
fail:
bdb_db_close( be );
bdb_db_close( be, NULL );
return rc;
}
static int
bdb_db_close( BackendDB *be )
bdb_db_close( BackendDB *be, ConfigArgs *ca )
{
int rc;
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
......@@ -574,7 +575,7 @@ bdb_db_close( BackendDB *be )
}
static int
bdb_db_destroy( BackendDB *be )
bdb_db_destroy( BackendDB *be, ConfigArgs *ca )
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
......
......@@ -24,8 +24,11 @@
#include <stdio.h>
#include <ac/socket.h>
#include <ac/param.h>
#include <ac/string.h>
#include "slap.h"
#include "config.h"
#include "proto-dnssrv.h"
int
......@@ -89,14 +92,16 @@ dnssrv_back_open(
int
dnssrv_back_db_init(
Backend *be )
Backend *be,
ConfigArgs *ca)
{
return 0;
}
int
dnssrv_back_db_destroy(
Backend *be )
Backend *be,
ConfigArgs *ca )
{
return 0;
}
......
......@@ -112,7 +112,7 @@ static int ldap_chain_db_init_common( BackendDB *be );
static int ldap_chain_db_init_one( BackendDB *be );
static int ldap_chain_db_open_one( BackendDB *be );
#define ldap_chain_db_close_one(be) (0)
#define ldap_chain_db_destroy_one(be) (lback)->bi_db_destroy( (be) )
#define ldap_chain_db_destroy_one(be, rs) (lback)->bi_db_destroy( (be), (rs) )
typedef struct ldap_chain_cb_t {
ldap_chain_status_t lb_status;
......@@ -507,7 +507,7 @@ Document: RFC 4511
if ( rc != 0 ) {
lip->li_uri = NULL;
lip->li_bvuri = NULL;
(void)ldap_chain_db_destroy_one( op->o_bd );
(void)ldap_chain_db_destroy_one( op->o_bd, NULL);
goto cleanup;
}
......@@ -546,7 +546,7 @@ cleanup:;
lip->li_uri = NULL;
lip->li_bvuri = NULL;
(void)ldap_chain_db_close_one( op->o_bd );
(void)ldap_chain_db_destroy_one( op->o_bd );
(void)ldap_chain_db_destroy_one( op->o_bd, NULL );
}
further_cleanup:;
......@@ -691,7 +691,7 @@ ldap_chain_search(
if ( rc != 0 ) {
lip->li_uri = NULL;
lip->li_bvuri = NULL;
(void)ldap_chain_db_destroy_one( op->o_bd );
(void)ldap_chain_db_destroy_one( op->o_bd, NULL );
goto cleanup;
}
......@@ -733,7 +733,7 @@ cleanup:;
lip->li_uri = NULL;
lip->li_bvuri = NULL;
(void)ldap_chain_db_close_one( op->o_bd );
(void)ldap_chain_db_destroy_one( op->o_bd );
(void)ldap_chain_db_destroy_one( op->o_bd, NULL );
}
further_cleanup:;
......@@ -1192,7 +1192,7 @@ chain_ldadd( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
done:;
if ( rc != LDAP_SUCCESS ) {
(void)ldap_chain_db_destroy_one( ca->be );
(void)ldap_chain_db_destroy_one( ca->be, NULL );
ch_free( ca->be );
ca->be = NULL;
}
......@@ -1506,7 +1506,8 @@ chain_cf_gen( ConfigArgs *c )
static int
ldap_chain_db_init(
BackendDB *be )
BackendDB *be,
ConfigArgs *ca )
{
slap_overinst *on = (slap_overinst *)be->bd_info;
ldap_chain_t *lc = NULL;
......@@ -1637,7 +1638,7 @@ private_destroy:;
db.bd_info = lback;
db.be_private = (void *)lc->lc_cfg_li;
ldap_chain_db_destroy_one( &db );
ldap_chain_db_destroy_one( &db, NULL );
lc->lc_cfg_li = NULL;
} else {
......@@ -1690,7 +1691,7 @@ ldap_chain_db_apply( void *datum, void *arg )
lca->be->be_private = (void *)li;
return lca->func( lca->be );
return lca->func( lca->be, NULL );
}
static int
......@@ -1713,7 +1714,7 @@ ldap_chain_db_func(
db.bd_info = lback;
db.be_private = lc->lc_common_li;
rc = func( &db );
rc = func( &db, NULL );
if ( rc != 0 ) {
return rc;
......@@ -1737,7 +1738,8 @@ ldap_chain_db_func(
static int
ldap_chain_db_open(
BackendDB *be )
BackendDB *be,
ConfigArgs *ca )
{
slap_overinst *on = (slap_overinst *) be->bd_info;
ldap_chain_t *lc = (ldap_chain_t *)on->on_bi.bi_private;
......@@ -1769,14 +1771,16 @@ ldap_chain_db_open(
static int
ldap_chain_db_close(
BackendDB *be )
BackendDB *be,
ConfigArgs *ca )
{
return ldap_chain_db_func( be, db_close );
}
static int
ldap_chain_db_destroy(
BackendDB *be )
BackendDB *be,
ConfigArgs *ca )
{
slap_overinst *on = (slap_overinst *) be->bd_info;
ldap_chain_t *lc = (ldap_chain_t *)on->on_bi.bi_private;
......@@ -1808,7 +1812,7 @@ ldap_chain_db_init_common(
be->bd_info = lback;
be->be_private = NULL;
rc = lback->bi_db_init( be );
rc = lback->bi_db_init( be, NULL );
if ( rc != 0 ) {
return rc;
}
......@@ -1843,7 +1847,7 @@ ldap_chain_db_init_one(
be->bd_info = lback;
be->be_private = NULL;
t = lback->bi_db_init( be );
t = lback->bi_db_init( be, NULL );
if ( t != 0 ) {
return t;
}
......@@ -1887,7 +1891,7 @@ ldap_chain_db_open_one(
}
}
return lback->bi_db_open( be );
return lback->bi_db_open( be, NULL );
}
typedef struct ldap_chain_conn_apply_t {
......
......@@ -237,7 +237,7 @@ static int ldap_distproc_db_init_common( BackendDB *be );
static int ldap_distproc_db_init_one( BackendDB *be );
#define ldap_distproc_db_open_one(be) (lback)->bi_db_open( (be) )
#define ldap_distproc_db_close_one(be) (0)
#define ldap_distproc_db_destroy_one(be) (lback)->bi_db_destroy( (be) )
#define ldap_distproc_db_destroy_one(be, ca) (lback)->bi_db_destroy( (be), (ca) )
static int
ldap_distproc_parse_ctrl(
......@@ -447,7 +447,7 @@ distproc_ldadd( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
done:;
if ( rc != LDAP_SUCCESS ) {
(void)ldap_distproc_db_destroy_one( ca->be );
(void)ldap_distproc_db_destroy_one( ca->be, NULL );
ch_free( ca->be );
ca->be = NULL;
}
......@@ -567,7 +567,8 @@ distproc_cfgen( ConfigArgs *c )
static int
ldap_distproc_db_init(
BackendDB *be )
BackendDB *be,
ConfigArgs *ca )
{
slap_overinst *on = (slap_overinst *)be->bd_info;
ldap_distproc_t *lc = NULL;
......@@ -659,7 +660,7 @@ private_destroy:;
db.bd_info = lback;
db.be_private = (void *)lc->lc_cfg_li;
ldap_distproc_db_destroy_one( &db );
ldap_distproc_db_destroy_one( &db, NULL );
lc->lc_cfg_li = NULL;
} else {
......@@ -712,7 +713,7 @@ ldap_distproc_db_apply( void *datum, void *arg )
lca->be->be_private = (void *)li;
return lca->func( lca->be );
return lca->func( lca->be, NULL );
}
static int
......@@ -735,7 +736,7 @@ ldap_distproc_db_func(
db.bd_info = lback;
db.be_private = lc->lc_common_li;
rc = func( &db );
rc = func( &db, NULL );
if ( rc != 0 ) {
return rc;
......@@ -759,21 +760,24 @@ ldap_distproc_db_func(
static int
ldap_distproc_db_open(
BackendDB *be )
BackendDB *be,
ConfigArgs *ca )
{
return ldap_distproc_db_func( be, db_open );
}
static int
ldap_distproc_db_close(
BackendDB *be )
BackendDB *be,
ConfigArgs *ca )
{
return ldap_distproc_db_func( be, db_close );
}
static int
ldap_distproc_db_destroy(
BackendDB *be )
BackendDB *be,
ConfigArgs *ca )
{
slap_overinst *on = (slap_overinst *) be->bd_info;
ldap_distproc_t *lc = (ldap_distproc_t *)on->on_bi.bi_private;
......@@ -804,7 +808,7 @@ ldap_distproc_db_init_common(
be->bd_info = lback;
be->be_private = NULL;
t = lback->bi_db_init( be );
t = lback->bi_db_init( be, NULL );
if ( t != 0 ) {
return t;
}
......@@ -835,7 +839,7 @@ ldap_distproc_db_init_one(
be->bd_info = lback;
be->be_private = NULL;
t = lback->bi_db_init( be );
t = lback->bi_db_init( be, NULL );
if ( t != 0 ) {
return t;
}
......
......@@ -29,6 +29,7 @@
#include <ac/socket.h>
#include "slap.h"
#include "config.h"
#include "back-ldap.h"
int
......@@ -98,7 +99,7 @@ ldap_back_initialize( BackendInfo *bi )
}
int
ldap_back_db_init( Backend *be )
ldap_back_db_init( Backend *be, ConfigArgs *ca )
{
ldapinfo_t *li;
int rc;
......@@ -168,7 +169,7 @@ ldap_back_db_init( Backend *be )
}
int
ldap_back_db_open( BackendDB *be )
ldap_back_db_open( BackendDB *be, ConfigArgs *ca )
{
ldapinfo_t *li = (ldapinfo_t *)be->be_private;
......@@ -255,7 +256,7 @@ ldap_back_conn_free( void *v_lc )
}
int
ldap_back_db_close( Backend *be )
ldap_back_db_close( Backend *be, ConfigArgs *ca )
{
int rc = 0;
......@@ -267,7 +268,7 @@ ldap_back_db_close( Backend *be )
}
int
ldap_back_db_destroy( Backend *be )
ldap_back_db_destroy( Backend *be, ConfigArgs *ca )
{
if ( be->be_private ) {
ldapinfo_t *li = ( ldapinfo_t * )be->be_private;
......
......@@ -1105,7 +1105,7 @@ int ldif_back_entry_get(
return ( *ent == NULL ? 1 : 0 );
}
static int ldif_tool_entry_open(BackendDB * be, int mode) {
static int ldif_tool_entry_open(BackendDB *be, int mode) {
struct ldif_info *ni = (struct ldif_info *) be->be_private;
ni->li_tool_current = 0;
return 0;
......@@ -1214,7 +1214,7 @@ static ID ldif_tool_entry_put(BackendDB * be, Entry * e, struct berval *text) {
}
static int
ldif_back_db_init( BackendDB *be )
ldif_back_db_init( BackendDB *be, ConfigArgs *ca )
{
struct ldif_info *ni;
......@@ -1226,9 +1226,7 @@ ldif_back_db_init( BackendDB *be )
}
static int
ldif_back_db_destroy(
Backend *be
)
ldif_back_db_destroy( Backend *be, ConfigArgs *ca )
{
struct ldif_info *ni = be->be_private;
......@@ -1239,9 +1237,7 @@ ldif_back_db_destroy(
}
static int
ldif_back_db_open(
Backend *be
)
ldif_back_db_open( Backend *be, ConfigArgs *ca)
{
struct ldif_info *ni = (struct ldif_info *) be->be_private;
if( BER_BVISEMPTY(&ni->li_base_path)) {/* missing base path */
......
......@@ -23,6 +23,7 @@
#include <ac/socket.h>
#include "slap.h"
#include "config.h"
#include "../back-ldap/back-ldap.h"
#include "back-meta.h"
......@@ -87,7 +88,8 @@ meta_back_initialize(
int
meta_back_db_init(
Backend *be )
Backend *be,
ConfigArgs *ca)
{
metainfo_t *mi;
int i;
......@@ -128,7 +130,8 @@ meta_back_db_init(
int
meta_back_db_open(
Backend *be )
Backend *be,
ConfigArgs *ca )
{
metainfo_t *mi = (metainfo_t *)be->be_private;
......@@ -328,7 +331,8 @@ target_free(
int
meta_back_db_destroy(
Backend *be )
Backend *be,
ConfigArgs *ca )
{
metainfo_t *mi;
......
......@@ -2050,7 +2050,8 @@ monitor_back_initialize(
int
monitor_back_db_init(
BackendDB *be )
BackendDB *be,
ConfigArgs *c)
{
int rc;
struct berval dn = BER_BVC( SLAPD_MONITOR_DN ),
......@@ -2064,8 +2065,9 @@ monitor_back_db_init(
* database monitor can be defined once only
*/
if ( be_monitor != NULL ) {
Debug( LDAP_DEBUG_ANY,
"only one monitor database is allowed\n", 0, 0, 0 );
if (c) {
snprintf(c->msg, sizeof(c->msg),"only one monitor database allowed");
}
return( -1 );
}
be_monitor = be;
......@@ -2108,10 +2110,12 @@ monitor_back_db_init(
type = oi->oi_orig->bi_type;
}
Debug( LDAP_DEBUG_ANY,
"\"monitor\" database serving namingContext \"%s\" "
"is hidden by \"%s\" database serving namingContext \"%s\".\n",
pdn.bv_val, type, be2->be_nsuffix[ 0 ].bv_val );
if (c) {
snprintf(((ConfigArgs*)c)->msg, sizeof(((ConfigArgs*)c)->msg),
"\"monitor\" database serving namingContext \"%s\" "
"is hidden by \"%s\" database serving namingContext \"%s\".\n",
pdn.bv_val, type, be2->be_nsuffix[ 0 ].bv_val );
}
return -1;
}
......@@ -2120,7 +2124,8 @@ monitor_back_db_init(
int
monitor_back_db_open(
BackendDB *be )
BackendDB *be,
ConfigArgs *ca)
{
monitor_info_t *mi = (monitor_info_t *)be->be_private;
struct monitor_subsys_t **ms;
......@@ -2459,7 +2464,8 @@ monitor_back_db_config(
int
monitor_back_db_destroy(
BackendDB *be )
BackendDB *be,
ConfigArgs *ca)
{
monitor_info_t *mi = ( monitor_info_t * )be->be_private;
......
......@@ -24,6 +24,7 @@
#include <ac/string.h>
#include "slap.h"
#include "config.h"
struct null_info {
int ni_bind_allowed;
......@@ -160,7 +161,7 @@ null_back_db_config(
}
static int
null_back_db_init( BackendDB *be )
null_back_db_init( BackendDB *be, ConfigArgs *ca )
{
struct null_info *ni = ch_calloc( 1, sizeof(struct null_info) );
ni->ni_bind_allowed = 0;
......@@ -170,7 +171,7 @@ null_back_db_init( BackendDB *be )
}
static int
null_back_db_destroy( Backend *be )
null_back_db_destroy( Backend *be, ConfigArgs *ca )
{
free( be->be_private );
return 0;
......
......@@ -16,7 +16,7 @@
*/
#include "perl_back.h"
#include "config.h"
/**********************************************************
*
* Close
......@@ -39,7 +39,8 @@ perl_back_close(
int
perl_back_db_destroy(
BackendDB *be
BackendDB *be,
ConfigArgs *ca
)
{
free( be->be_private );
......
......@@ -16,6 +16,7 @@
*/
#include "perl_back.h"
#include "config.h"
static void perl_back_xs_init LDAP_P((PERL_BACK_XS_INIT_PARAMS));
EXT void boot_DynaLoader LDAP_P((PERL_BACK_BOOT_DYNALOADER_PARAMS));
......@@ -85,7 +86,8 @@ perl_back_initialize(
int
perl_back_db_init(
BackendDB *be
BackendDB *be,
ConfigArgs *ca
)
{
be->be_private = (PerlBackend *) ch_malloc( sizeof(PerlBackend) );
......@@ -100,7 +102,8 @@ perl_back_db_init(
int
perl_back_db_open(
BackendDB *be
BackendDB *be,
ConfigArgs *ca
)
{
int count;
......
......@@ -24,6 +24,7 @@
#include <ac/string.h>
#include "slap.h"
#include "config.h"
#include "back-relay.h"
int
......@@ -69,7 +70,7 @@ relay_back_initialize( BackendInfo *bi )
}
int
relay_back_db_init( Backend *be )
relay_back_db_init( Backend *be, ConfigArgs *ca)
{
relay_back_info *ri;
......@@ -90,7 +91,7 @@ relay_back_db_init( Backend *be )
}
int
relay_back_db_open( Backend *be )
relay_back_db_open( Backend *be, ConfigArgs *ca )
{
relay_back_info *ri = (relay_back_info *)be->be_private;