X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fbackover.c;h=46bd7a439e808a93634a997631aa1e9efe308e09;hb=113727ba53c91ab6f1b0880c5908eca43b89ec4e;hp=ceeb6011afb7ff7f7ff5bb9adba8412df92b3431;hpb=62da6969dc6a3fb81d873eee8b5d2bf779a0e5b3;p=openldap
diff --git a/servers/slapd/backover.c b/servers/slapd/backover.c
index ceeb6011af..46bd7a439e 100644
--- a/servers/slapd/backover.c
+++ b/servers/slapd/backover.c
@@ -1,16 +1,21 @@
/* backover.c - backend overlay routines */
/* $OpenLDAP$ */
-/*
- * Copyright 2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-
-/*
- * Functions to overlay other modules over a backend.
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 2003 The OpenLDAP Foundation.
+ * All rights reserved.
*
- * -- Howard Chu
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * .
*/
+/* Functions to overlay other modules over a backend. */
+
#include "portable.h"
#include
@@ -37,7 +42,7 @@ over_db_func(
BI_db_open **func;
int rc = 0;
- func = &oi->oi_bi.bi_db_open;
+ func = &oi->oi_bd.bd_info->bi_db_open;
if ( func[which] ) {
rc = func[which]( &oi->oi_bd );
if ( rc ) return rc;
@@ -69,10 +74,10 @@ over_db_config(
BackendDB bd;
int rc = 0;
- if ( oi->oi_bi.bi_db_config ) {
- rc = oi->oi_bi.bi_db_config( &oi->oi_bd, fname, lineno,
+ if ( oi->oi_bd.bd_info->bi_db_config ) {
+ rc = oi->oi_bd.bd_info->bi_db_config( &oi->oi_bd, fname, lineno,
argc, argv );
- if ( rc ) return rc;
+ if ( rc != SLAP_CONF_UNKNOWN ) return rc;
}
bd = *be;
@@ -81,7 +86,7 @@ over_db_config(
if (on->on_bi.bi_db_config) {
rc = on->on_bi.bi_db_config( &bd, fname, lineno,
argc, argv );
- if ( rc ) break;
+ if ( rc != SLAP_CONF_UNKNOWN ) break;
}
}
return rc;
@@ -127,7 +132,7 @@ over_back_response ( Operation *op, SlapReply *rs )
{
slap_overinfo *oi = (slap_overinfo *) op->o_bd->bd_info;
slap_overinst *on = oi->oi_list;
- int rc = 0;
+ int rc = SLAP_CB_CONTINUE;
BackendDB *be = op->o_bd, db = *op->o_bd;
op->o_bd = &db;
@@ -135,7 +140,7 @@ over_back_response ( Operation *op, SlapReply *rs )
if ( on->on_response ) {
db.bd_info = (BackendInfo *)on;
rc = on->on_response( op, rs );
- if ( rc ) break;
+ if ( rc != SLAP_CB_CONTINUE ) break;
}
}
op->o_bd = be;
@@ -155,26 +160,34 @@ over_op_func(
{
slap_overinfo *oi = (slap_overinfo *) op->o_bd->bd_info;
slap_overinst *on = oi->oi_list;
- int rc = 0;
- BackendDB *be = op->o_bd, db = *op->o_bd;
BI_op_bind **func;
- slap_callback cb = {over_back_response, NULL};
+ BackendDB *be = op->o_bd, db = *op->o_bd;
+ slap_callback cb = {NULL, over_back_response, NULL, NULL};
+ int rc = SLAP_CB_CONTINUE;
op->o_bd = &db;
+ cb.sc_next = op->o_callback;
+ op->o_callback = &cb;
+
for (; on; on=on->on_next ) {
func = &on->on_bi.bi_op_bind;
if ( func[which] ) {
db.bd_info = (BackendInfo *)on;
rc = func[which]( op, rs );
- if ( rc ) break;
+ if ( rc != SLAP_CB_CONTINUE ) break;
}
}
- func = &oi->oi_bi.bi_op_bind;
- if ( func[which] ) {
- rc = func[which]( op, rs );
- }
op->o_bd = be;
+ func = &oi->oi_bd.bd_info->bi_op_bind;
+ if ( func[which] && rc == SLAP_CB_CONTINUE ) {
+ rc = func[which]( op, rs );
+ }
+ /* should not fall thru this far without anything happening... */
+ if ( rc == SLAP_CB_CONTINUE ) {
+ rc = LDAP_UNWILLING_TO_PERFORM;
+ }
+ op->o_callback = cb.sc_next;
return rc;
}
@@ -273,6 +286,9 @@ overlay_config( BackendDB *be, const char *ov )
return 1;
}
+ /* If this is the first overlay on this backend, set up the
+ * overlay info structure
+ */
if ( be->bd_info->bi_type != overtype ) {
oi = ch_malloc( sizeof(slap_overinfo) );
oi->oi_bd = *be;
@@ -302,15 +318,27 @@ overlay_config( BackendDB *be, const char *ov )
be->bd_info = bi;
}
+ /* Walk to the end of the list of overlays, add the new
+ * one onto the end
+ */
oi = (slap_overinfo *) be->bd_info;
for ( prev=NULL, on2 = oi->oi_list; on2; prev=on2, on2=on2->on_next );
- on2 = ch_malloc( sizeof(slap_overinst) );
+ on2 = ch_calloc( 1, sizeof(slap_overinst) );
if ( !prev ) {
oi->oi_list = on2;
} else {
prev->on_next = on2;
}
*on2 = *on;
+ on2->on_next = NULL;
+ on2->on_info = oi;
+
+ /* Any initialization needed? */
+ if ( on->on_bi.bi_db_init ) {
+ be->bd_info = (BackendInfo *)on2;
+ on2->on_bi.bi_db_init( be );
+ be->bd_info = (BackendInfo *)oi;
+ }
return 0;
}