]> git.sur5r.net Git - openldap/commitdiff
ITS#5346 from HEAD
authorHoward Chu <hyc@openldap.org>
Thu, 24 Apr 2008 10:13:39 +0000 (10:13 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 24 Apr 2008 10:13:39 +0000 (10:13 +0000)
servers/slapd/back-monitor/init.c
servers/slapd/backend.c
servers/slapd/backover.c
servers/slapd/frontend.c
servers/slapd/slap.h

index 1f82cfa9a411442d9ff3a961f397f33f8240b6e1..3fd6cf978d31959ca6ed616cf4310736ef472bd2 100644 (file)
@@ -356,7 +356,7 @@ monitor_back_register_database_limbo(
 
        el.el_type = LIMBO_DATABASE;
 
-       el.el_be = be;
+       el.el_be = be->bd_self;
        el.el_ndn = ndn;
        
        for ( elpp = &mi->mi_entry_limbo;
index 1314c10e6adfb72b8b6482e71d5d1fcc62a74ec2..78c655cc64cb8e3fdcdb7c06a48a0b112ac3dd3a 100644 (file)
@@ -585,6 +585,7 @@ backend_db_init(
        }
 
        be->bd_info = bi;
+       be->bd_self = be;
 
        be->be_def_limit = frontendDB->be_def_limit;
        be->be_dfltaccess = frontendDB->be_dfltaccess;
index 8d3ed4022e355b6a8854095503518df6321c3808..46d879b63bea5c2bb15d31e9f3f4406a4c4a750c 100644 (file)
 
 static slap_overinst *overlays;
 
-enum db_which {
-       db_open = 0,
-       db_close,
-       db_destroy,
-       db_last
-};
-
-static int
-over_db_func(
-       BackendDB *be,
-       ConfigReply *cr,
-       enum db_which which
-)
-{
-       slap_overinfo *oi = be->bd_info->bi_private;
-       slap_overinst *on = oi->oi_list;
-       BackendInfo *bi_orig = be->bd_info;
-       BI_db_open **func;
-       int rc = 0;
-
-       func = &oi->oi_orig->bi_db_open;
-       if ( func[which] ) {
-               be->bd_info = oi->oi_orig;
-               rc = func[which]( be, cr );
-       }
-
-       for (; on && rc == 0; on=on->on_next) {
-               be->bd_info = &on->on_bi;
-               func = &on->on_bi.bi_db_open;
-               if (func[which]) {
-                       rc = func[which]( be, cr );
-               }
-       }
-       be->bd_info = bi_orig;
-       return rc;
-}
-
 static int
 over_db_config(
        BackendDB *be,
@@ -173,7 +136,25 @@ over_db_open(
        ConfigReply *cr
 )
 {
-       return over_db_func( be, cr, db_open );
+       slap_overinfo *oi = be->bd_info->bi_private;
+       slap_overinst *on = oi->oi_list;
+       BackendDB db = *be;
+       int rc = 0;
+
+       db.be_flags |= SLAP_DBFLAG_OVERLAY;
+       db.bd_info = oi->oi_orig;
+       if ( db.bd_info->bi_db_open ) {
+               rc = db.bd_info->bi_db_open( &db, cr );
+       }
+
+       for (; on && rc == 0; on=on->on_next) {
+               db.bd_info = &on->on_bi;
+               if ( db.bd_info->bi_db_open ) {
+                       rc = db.bd_info->bi_db_open( &db, cr );
+               }
+       }
+
+       return rc;
 }
 
 static int
@@ -211,17 +192,29 @@ over_db_destroy(
 {
        slap_overinfo *oi = be->bd_info->bi_private;
        slap_overinst *on = oi->oi_list, *next;
+       BackendInfo *bi_orig = be->bd_info;
        int rc;
 
-       rc = over_db_func( be, cr, db_destroy );
+       be->bd_info = oi->oi_orig;
+       if ( be->bd_info->bi_db_destroy ) {
+               rc = be->bd_info->bi_db_destroy( be, cr );
+       }
 
+       for (; on && rc == 0; on=on->on_next) {
+               be->bd_info = &on->on_bi;
+               if ( be->bd_info->bi_db_destroy ) {
+                       rc = be->bd_info->bi_db_destroy( be, cr );
+               }
+       }
+
+       on = oi->oi_list;
        if ( on ) {
                for (next = on->on_next; on; on=next) {
                        next = on->on_next;
                        free( on );
                }
        }
-
+       be->bd_info = bi_orig;
        free( oi );
        return rc;
 }
index 63271f6882057cdb933ca38efe19a869309a5617..4ab36e5a2a3ba8c57856ce5b9dac7d6a671c0138 100644 (file)
@@ -93,6 +93,7 @@ frontend_init( void )
 {
        /* data */
        frontendDB = &slap_frontendDB;
+       frontendDB->bd_self = frontendDB;
 
        /* ACLs */
        frontendDB->be_dfltaccess = ACL_READ;
index 8507e3cc93ef5b6659b567a726eabcc2a15d569c..da02058f8ce86548ad447edec5051019ee335243 100644 (file)
@@ -1707,6 +1707,7 @@ struct ConfigOCs; /* config.h */
 
 struct BackendDB {
        BackendInfo     *bd_info;       /* pointer to shared backend info */
+       BackendDB       *bd_self;       /* pointer to this struct */
 
        /* fields in this structure (and routines acting on this structure)
           should be renamed from be_ to bd_ */