]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backend.c
Fix ITS#3424
[openldap] / servers / slapd / backend.c
index fc41d3a252db73aefe4ad940b1f65a59db772f9f..d04e0041a8b33a4dd10e4b5306f795a55666936f 100644 (file)
@@ -183,8 +183,6 @@ int backend_startup_one(Backend *be)
 
        be->be_pending_csn_list = (struct be_pcl *)
                ch_calloc( 1, sizeof( struct be_pcl ));
-       build_new_dn( &be->be_context_csn, be->be_nsuffix,
-               (struct berval *)&slap_ldapsync_cn_bv, NULL );
 
        LDAP_TAILQ_INIT( be->be_pending_csn_list );
 
@@ -261,9 +259,9 @@ int backend_startup(Backend *be)
                }
        }
 
-       ldap_pvt_thread_mutex_init( &syncrepl_rq.rq_mutex );
-       LDAP_STAILQ_INIT( &syncrepl_rq.task_list );
-       LDAP_STAILQ_INIT( &syncrepl_rq.run_list );
+       ldap_pvt_thread_mutex_init( &slapd_rq.rq_mutex );
+       LDAP_STAILQ_INIT( &slapd_rq.task_list );
+       LDAP_STAILQ_INIT( &slapd_rq.run_list );
 
        /* open each backend database */
        for( i = 0; i < nBackendDB; i++ ) {
@@ -295,10 +293,10 @@ int backend_startup(Backend *be)
                        LDAP_STAILQ_FOREACH( si, &backendDB[i].be_syncinfo, si_next ) {
                                si->si_be = &backendDB[i];
                                init_syncrepl( si );
-                               ldap_pvt_thread_mutex_lock( &syncrepl_rq.rq_mutex );
-                               ldap_pvt_runqueue_insert( &syncrepl_rq,
+                               ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
+                               ldap_pvt_runqueue_insert( &slapd_rq,
                                                si->si_interval, do_syncrepl, (void *) si );
-                               ldap_pvt_thread_mutex_unlock( &syncrepl_rq.rq_mutex );
+                               ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
                        }
                }
        }
@@ -406,8 +404,7 @@ int backend_destroy(void)
                                struct slap_csn_entry *tmp_csne = csne;
 
                                LDAP_TAILQ_REMOVE( bd->be_pending_csn_list, csne, ce_csn_link );
-                               ch_free( csne->ce_csn->bv_val );
-                               ch_free( csne->ce_csn );
+                               ch_free( csne->ce_csn.bv_val );
                                csne = LDAP_TAILQ_NEXT( csne, ce_csn_link );
                                ch_free( tmp_csne );
                        }
@@ -421,7 +418,6 @@ int backend_destroy(void)
                if ( bd->be_rootdn.bv_val ) free( bd->be_rootdn.bv_val );
                if ( bd->be_rootndn.bv_val ) free( bd->be_rootndn.bv_val );
                if ( bd->be_rootpw.bv_val ) free( bd->be_rootpw.bv_val );
-               if ( bd->be_context_csn.bv_val ) free( bd->be_context_csn.bv_val );
                acl_destroy( bd->be_acl, frontendDB->be_acl );
        }
        free( backendDB );
@@ -445,15 +441,17 @@ int backend_destroy(void)
 
        /* destroy frontend database */
        bd = frontendDB;
-       if ( bd->bd_info->bi_db_destroy ) {
-               bd->bd_info->bi_db_destroy( bd );
+       if ( bd ) {
+               if ( bd->bd_info->bi_db_destroy ) {
+                       bd->bd_info->bi_db_destroy( bd );
+               }
+               ber_bvarray_free( bd->be_suffix );
+               ber_bvarray_free( bd->be_nsuffix );
+               if ( bd->be_rootdn.bv_val ) free( bd->be_rootdn.bv_val );
+               if ( bd->be_rootndn.bv_val ) free( bd->be_rootndn.bv_val );
+               if ( bd->be_rootpw.bv_val ) free( bd->be_rootpw.bv_val );
+               acl_destroy( bd->be_acl, frontendDB->be_acl );
        }
-       ber_bvarray_free( bd->be_suffix );
-       ber_bvarray_free( bd->be_nsuffix );
-       if ( bd->be_rootdn.bv_val ) free( bd->be_rootdn.bv_val );
-       if ( bd->be_rootndn.bv_val ) free( bd->be_rootndn.bv_val );
-       if ( bd->be_rootpw.bv_val ) free( bd->be_rootpw.bv_val );
-       acl_destroy( bd->be_acl, frontendDB->be_acl );
 
        return 0;
 }
@@ -512,8 +510,6 @@ backend_db_init(
        be->be_requires = frontendDB->be_requires;
        be->be_ssf_set = frontendDB->be_ssf_set;
 
-       be->be_context_csn.bv_len = 0;
-       be->be_context_csn.bv_val = NULL;
        be->be_pcl_mutexp = &be->be_pcl_mutex;
        ldap_pvt_thread_mutex_init( be->be_pcl_mutexp );
 
@@ -1246,7 +1242,6 @@ backend_group(
                                Filter *filter;
                                Entry *user;
                                Backend *b2 = op->o_bd;
-                               void *o_private = op->o_private;
 
                                if ( target && dn_match( &target->e_nname, op_ndn ) ) {
                                        user = target;
@@ -1254,7 +1249,6 @@ backend_group(
                                        /* back-bdb stored lockinfo here, we saved it
                                         * above. Clear it out so that a new lock can be used.
                                         */
-                                       op->o_private = NULL;
                                        op->o_bd = select_backend( op_ndn, 0, 0 );
                                        rc = be_entry_get_rw(op, op_ndn, NULL, NULL, 0, &user );
                                }
@@ -1319,8 +1313,6 @@ loopit:
                                        }
                                        if ( user != target ) {
                                                be_entry_release_r( op, user );
-                                               /* restore previous lockinfo, if any */
-                                               op->o_private = o_private;
                                        }
                                }
                                op->o_bd = b2;
@@ -1509,6 +1501,7 @@ int backend_operational(
 {
        Attribute       **ap;
        int             rc = 0;
+       BackendDB *be_orig;
 
        for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next )
                /* just count them */ ;
@@ -1532,6 +1525,11 @@ int backend_operational(
                ap = &(*ap)->a_next;
        }
 
+       /* Let the overlays have a chance at this */
+       be_orig = op->o_bd;
+       if ( SLAP_ISOVERLAY( be_orig ))
+               op->o_bd = select_backend( be_orig->be_nsuffix, 0, 0 );
+
        if (( SLAP_OPATTRS( rs->sr_attr_flags ) || op->ors_attrs ) &&
                op->o_bd && op->o_bd->be_operational != NULL )
        {
@@ -1548,6 +1546,7 @@ int backend_operational(
                for ( ; *ap; ap = &(*ap)->a_next )
                        /* just count them */ ;
        }
+       op->o_bd = be_orig;
 
        return rc;
 }