]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backglue.c
Fix typo
[openldap] / servers / slapd / backglue.c
index 631d3323e5dd9159f12ff683039a70e7ca5bbd52..78d0633cc2f82c2406173f3e20b4e598d4afbe74 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2006 The OpenLDAP Foundation.
+ * Copyright 2001-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,7 @@
 
 #define SLAPD_TOOLS
 #include "slap.h"
+#include "config.h"
 
 typedef struct gluenode {
        BackendDB *gn_be;
@@ -87,6 +88,15 @@ typedef struct glue_state {
        int nctrls;
 } glue_state;
 
+static int
+glue_op_cleanup( Operation *op, SlapReply *rs )
+{
+       /* This is not a final result */
+       if (rs->sr_type == REP_RESULT )
+               rs->sr_type = REP_GLUE_RESULT;
+       return SLAP_CB_CONTINUE;
+}
+
 static int
 glue_op_response ( Operation *op, SlapReply *rs )
 {
@@ -165,8 +175,6 @@ glue_op_response ( Operation *op, SlapReply *rs )
                        gs->nctrls = j;
                        gs->ctrls = newctrls;
                }
-               /* This is not a final result */
-               rs->sr_type = REP_GLUE_RESULT;
        }
        return 0;
 }
@@ -212,7 +220,6 @@ glue_op_func ( Operation *op, SlapReply *rs )
 static int
 glue_response ( Operation *op, SlapReply *rs )
 {
-       slap_overinst   *on = (slap_overinst *)op->o_bd->bd_info;
        BackendDB *be = op->o_bd;
        be = glue_back_select (op->o_bd, &op->o_req_ndn);
 
@@ -319,7 +326,7 @@ glue_op_search ( Operation *op, SlapReply *rs )
        int i;
        long stoptime = 0, starttime;
        glue_state gs = {NULL, NULL, NULL, 0, 0, 0, 0};
-       slap_callback cb = { NULL, glue_op_response, NULL, NULL };
+       slap_callback cb = { NULL, glue_op_response, glue_op_cleanup, NULL };
        int scope0, tlimit0;
        struct berval dn, ndn, *pdn;
 
@@ -577,7 +584,7 @@ glue_open (
                                        gi->gi_n[i].gn_be->bd_info );
                        /* Let backend.c take care of the rest of startup */
                        if ( !rc )
-                               rc = backend_startup_one( gi->gi_n[i].gn_be );
+                               rc = backend_startup_one( gi->gi_n[i].gn_be, NULL );
                        if ( rc ) break;
                }
                if ( !rc && !bsame && on->on_info->oi_orig->bi_open )
@@ -606,6 +613,28 @@ glue_close (
        return rc;
 }
 
+static int
+glue_entry_get_rw (
+       Operation               *op,
+       struct berval   *dn,
+       ObjectClass             *oc,
+       AttributeDescription    *ad,
+       int     rw,
+       Entry   **e )
+{
+       int rc;
+       BackendDB *b0 = op->o_bd;
+       op->o_bd = glue_back_select( b0, dn );
+
+       if ( op->o_bd->be_fetch ) {
+               rc = op->o_bd->be_fetch( op, dn, oc, ad, rw, e );
+       } else {
+               rc = LDAP_UNWILLING_TO_PERFORM;
+       }
+       op->o_bd =b0;
+       return rc;
+}
+
 static int
 glue_entry_release_rw (
        Operation *op,
@@ -613,13 +642,10 @@ glue_entry_release_rw (
        int rw
 )
 {
-       BackendDB *b0, b2;
+       BackendDB *b0 = op->o_bd;
        int rc = -1;
 
-       b0 = op->o_bd;
-       b2 = *op->o_bd;
-       b2.bd_info = (BackendInfo *)glue_tool_inst( op->o_bd->bd_info );
-       op->o_bd = glue_back_select (&b2, &e->e_nname);
+       op->o_bd = glue_back_select (b0, &e->e_nname);
 
        if ( op->o_bd->be_release ) {
                rc = op->o_bd->be_release( op, e, rw );
@@ -758,13 +784,14 @@ glue_tool_entry_put (
 static int
 glue_tool_entry_reindex (
        BackendDB *b0,
-       ID id
+       ID id,
+       AttributeDescription **adv
 )
 {
        if (!glueBack || !glueBack->be_entry_reindex)
                return -1;
 
-       return glueBack->be_entry_reindex (glueBack, id);
+       return glueBack->be_entry_reindex (glueBack, id, adv);
 }
 
 static int
@@ -790,7 +817,8 @@ glue_tool_sync (
 
 static int
 glue_db_init(
-       BackendDB *be
+       BackendDB *be,
+       ConfigReply *cr
 )
 {
        slap_overinst   *on = (slap_overinst *)be->bd_info;
@@ -815,8 +843,6 @@ glue_db_init(
        oi->oi_bi.bi_open = glue_open;
        oi->oi_bi.bi_close = glue_close;
 
-       oi->oi_bi.bi_entry_release_rw = glue_entry_release_rw;
-
        /* Only advertise these if the root DB supports them */
        if ( bi->bi_tool_entry_open )
                oi->oi_bi.bi_tool_entry_open = glue_tool_entry_open;
@@ -837,7 +863,6 @@ glue_db_init(
 
        /*FIXME : need to add support */
        oi->oi_bi.bi_tool_dn2id_get = 0;
-       oi->oi_bi.bi_tool_id2entry_get = 0;
        oi->oi_bi.bi_tool_entry_modify = 0;
 
        SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_INSTANCE;
@@ -847,7 +872,8 @@ glue_db_init(
 
 static int
 glue_db_destroy (
-       BackendDB *be
+       BackendDB *be,
+       ConfigReply *cr
 )
 {
        slap_overinst   *on = (slap_overinst *)be->bd_info;
@@ -859,7 +885,8 @@ glue_db_destroy (
 
 static int
 glue_db_close( 
-       BackendDB *be
+       BackendDB *be,
+       ConfigReply *cr
 )
 {
        slap_overinst   *on = (slap_overinst *)be->bd_info;
@@ -949,7 +976,7 @@ glue_sub_attach()
 
                        /* If it's not already configured, set up the overlay */
                        if ( !SLAP_GLUE_INSTANCE( be )) {
-                               rc = overlay_config( be, glue.on_bi.bi_type );
+                               rc = overlay_config( be, glue.on_bi.bi_type, -1, NULL );
                                if ( rc )
                                        break;
                        }
@@ -1029,6 +1056,9 @@ glue_sub_init()
 
        glue.on_bi.bi_chk_referrals = glue_chk_referrals;
        glue.on_bi.bi_chk_controls = glue_chk_controls;
+       glue.on_bi.bi_entry_get_rw = glue_entry_get_rw;
+       glue.on_bi.bi_entry_release_rw = glue_entry_release_rw;
+
        glue.on_response = glue_response;
 
        return overlay_register( &glue );