]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/modrdn.c
Remove broken MSVC build from REL_ENG branch.
[openldap] / servers / slapd / back-bdb / modrdn.c
index 18f14807aa7d7e2de4c1dad3a7220e0bbcf07327..50f0ad614326e48e2a7bf1598a14f487fc8030ac 100644 (file)
@@ -1,8 +1,17 @@
 /* modrdn.c - bdb backend modrdn routine */
 /* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2000-2003 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * 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
+ * <http://www.OpenLDAP.org/license.html>.
  */
 
 #include "portable.h"
@@ -173,8 +182,17 @@ retry:     /* transaction retry */
                        e = NULL;
 
                } else {
-                       BerVarray deref = op->o_bd->be_syncinfo ?
-                               op->o_bd->be_syncinfo->si_provideruri_bv : default_referral;
+                       BerVarray deref = NULL;
+                       if ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
+                               syncinfo_t *si;
+                               LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
+                                       struct berval tmpbv;
+                                       ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
+                                       ber_bvarray_add( &deref, &tmpbv );
+                }
+                       } else {
+                               deref = default_referral;
+                       }
                        rs->sr_ref = referral_rewrite( deref, NULL, &op->o_req_dn,
                                LDAP_SCOPE_DEFAULT );
                }
@@ -865,9 +883,11 @@ retry:     /* transaction retry */
        }
 
        if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop && !op->o_no_psearch ) {
+               ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
                LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
                        bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_PREMODIFY );
                }
+               ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock );
        }
 
        /* modify entry */
@@ -940,7 +960,7 @@ retry:      /* transaction retry */
                goto return_results;
        }
 
-       if ( !op->o_bd->be_syncinfo ) {
+       if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
                rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei,
                        &ctxcsn_e, &ctxcsn_added, locker );
                switch ( rc ) {
@@ -972,13 +992,31 @@ retry:    /* transaction retry */
                        bdb_cache_modrdn( save, &op->orr_nnewrdn, e, neip,
                                bdb->bi_dbenv, locker, &lock );
 
-                       if ( !op->o_bd->be_syncinfo ) {
+                       if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
                                if ( ctxcsn_added ) {
                                        bdb_cache_add( bdb, suffix_ei, ctxcsn_e,
                                                (struct berval *)&slap_ldapsync_cn_bv, locker );
                                }
                        }
 
+                       if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
+                               /* Loop through in-scope entries for each psearch spec */
+                               ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
+                               LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
+                                       bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY );
+                               }
+                               ldap_pvt_thread_rdwr_runlock( &bdb->bi_pslist_rwlock );
+                               pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
+                               while ( pm_list != NULL ) {
+                                       bdb_psearch(op, rs, pm_list->ps_op,
+                                                               e, LDAP_PSEARCH_BY_SCOPEOUT);
+                                       pm_prev = pm_list;
+                                       LDAP_LIST_REMOVE ( pm_list, ps_link );
+                                       pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
+                                       ch_free( pm_prev );
+                               }
+                       }
+
                        if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) {
                                rs->sr_text = "txn_commit failed";
                        } else {
@@ -1018,22 +1056,6 @@ retry:   /* transaction retry */
 return_results:
        send_ldap_result( op, rs );
 
-       if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
-               /* Loop through in-scope entries for each psearch spec */
-               LDAP_LIST_FOREACH ( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
-                       bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_MODIFY );
-               }
-               pm_list = LDAP_LIST_FIRST(&op->o_pm_list);
-               while ( pm_list != NULL ) {
-                       bdb_psearch(op, rs, pm_list->ps_op,
-                                               e, LDAP_PSEARCH_BY_SCOPEOUT);
-                       pm_prev = pm_list;
-                       LDAP_LIST_REMOVE ( pm_list, ps_link );
-                       pm_list = LDAP_LIST_NEXT ( pm_list, ps_link );
-                       ch_free( pm_prev );
-               }
-       }
-
        if( rs->sr_err == LDAP_SUCCESS && bdb->bi_txn_cp ) {
                ldap_pvt_thread_yield();
                TXN_CHECKPOINT( bdb->bi_dbenv,