]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/syncrepl.c
minor naming cleanup; improvements to DN mapping layer; major docs update
[openldap] / servers / slapd / syncrepl.c
index fe4e41e47bd9ea917d411ee1f9c1583c35a4d9c5..59619373ce374228e2394db5a5c1999124d4e97c 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2004 The OpenLDAP Foundation.
+ * Copyright 2003-2005 The OpenLDAP Foundation.
  * Portions Copyright 2003 by IBM Corporation.
  * Portions Copyright 2003 by Howard Chu, Symas Corporation.
  * All rights reserved.
@@ -715,11 +715,6 @@ do_syncrep2(
                                                ber_scanf( ber, "tm", &tag, &cookie );
                                                break;
                                        case LDAP_TAG_SYNC_REFRESH_DELETE:
-                                               Debug( LDAP_DEBUG_SYNC,
-                                                       "do_syncrep2: %s - %s%s\n", 
-                                                       "LDAP_RES_INTERMEDIATE", 
-                                                       "REFRESH_DELETE\n", "\n" );
-                                               si->si_refreshDelete = 1;
                                        case LDAP_TAG_SYNC_REFRESH_PRESENT:
                                                Debug( LDAP_DEBUG_SYNC,
                                                        "do_syncrep2: %s - %s%s\n", 
@@ -727,8 +722,11 @@ do_syncrep2(
                                                        si_tag == LDAP_TAG_SYNC_REFRESH_PRESENT ?
                                                        "REFRESH_PRESENT" : "REFRESH_DELETE",
                                                        "\n" );
-                                               si->si_refreshDelete = 1;
-                                               si->si_refreshPresent = 1;
+                                               if ( si_tag == LDAP_TAG_SYNC_REFRESH_DELETE ) {
+                                                       si->si_refreshDelete = 1;
+                                               } else {
+                                                       si->si_refreshPresent = 1;
+                                               }
                                                ber_scanf( ber, "t{" /*"}"*/, &tag );
                                                if ( ber_peek_tag( ber, &len ) == LDAP_TAG_SYNC_COOKIE )
                                                {
@@ -914,11 +912,13 @@ do_syncrepl(
                return NULL;
        }
 
-       if ( slapd_shutdown && si->si_ld ) {
-               ldap_get_option( si->si_ld, LDAP_OPT_DESC, &s );
-               connection_client_stop( s );
-               ldap_unbind( si->si_ld );
-               si->si_ld = NULL;
+       if ( slapd_shutdown ) {
+               if ( si->si_ld ) {
+                       ldap_get_option( si->si_ld, LDAP_OPT_DESC, &s );
+                       connection_client_stop( s );
+                       ldap_unbind( si->si_ld );
+                       si->si_ld = NULL;
+               }
                return NULL;
        }
 
@@ -1107,7 +1107,7 @@ syncrepl_message_to_entry(
                goto done;
        }
 
-       rc = slap_mods_check( *modlist, 1, &text, txtbuf, textlen, NULL );
+       rc = slap_mods_check( *modlist, &text, txtbuf, textlen, NULL );
 
        if ( rc != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: mods check (%s)\n",
@@ -1158,6 +1158,8 @@ done:
        return rc;
 }
 
+static struct berval generic_filterstr = BER_BVC("(objectclass=*)");
+
 /* During a refresh, we may get an LDAP_SYNC_ADD for an already existing
  * entry if a previous refresh was interrupted before sending us a new
  * context state. We try to compare the new entry to the existing entry
@@ -1370,7 +1372,10 @@ retry_add:;
                        /* if an entry was added via syncrepl_add_glue(),
                         * it likely has no entryUUID, so the previous
                         * be_search() doesn't find it.  In this case,
-                        * give syncrepl a chance to modify it. */
+                        * give syncrepl a chance to modify it. Also
+                        * allow for entries that were recreated with the
+                        * same DN but a different entryUUID.
+                        */
                        case LDAP_ALREADY_EXISTS:
                                if ( retry ) {
                                        Operation       op2 = *op;
@@ -1378,12 +1383,8 @@ retry_add:;
                                        slap_callback   cb2 = { 0 };
 
                                        op2.o_tag = LDAP_REQ_SEARCH;
-                                       ber_dupbv_x( &op2.o_req_dn,
-                                               &entry->e_name,
-                                               op2.o_tmpmemctx );
-                                       ber_dupbv_x( &op2.o_req_ndn,
-                                               &entry->e_nname,
-                                               op2.o_tmpmemctx );
+                                       op2.o_req_dn = entry->e_name;
+                                       op2.o_req_ndn = entry->e_nname;
                                        op2.ors_scope = LDAP_SCOPE_BASE;
                                        op2.ors_attrs = slap_anlist_all_attributes;
                                        op2.ors_attrsonly = 0;
@@ -1391,15 +1392,10 @@ retry_add:;
                                        op2.ors_slimit = 1;
                                        op2.ors_tlimit = SLAP_NO_LIMIT;
 
-                                       f.f_choice = LDAP_FILTER_EQUALITY;
-                                       f.f_ava = &ava;
-                                       ava.aa_desc = slap_schema.si_ad_objectClass;
-                                       ber_dupbv_x( &ava.aa_value,
-                                               &slap_schema.si_oc_glue->soc_cname,
-                                               op2.o_tmpmemctx );
+                                       f.f_choice = LDAP_FILTER_PRESENT;
+                                       f.f_desc = slap_schema.si_ad_objectClass;
                                        op2.ors_filter = &f;
-                                       filter2bv_x( &op2, op2.ors_filter,
-                                                       &op2.ors_filterstr );
+                                       op2.ors_filterstr = generic_filterstr;
 
                                        op2.o_callback = &cb2;
                                        cb2.sc_response = dn_callback;
@@ -1407,15 +1403,6 @@ retry_add:;
 
                                        be->be_search( &op2, &rs2 );
 
-                                       op2.o_tmpfree( op2.o_req_dn.bv_val,
-                                               op2.o_tmpmemctx );
-                                       op2.o_tmpfree( op2.o_req_ndn.bv_val,
-                                               op2.o_tmpmemctx );
-                                       op2.o_tmpfree( ava.aa_value.bv_val,
-                                               op2.o_tmpmemctx );
-                                       op2.o_tmpfree( op2.ors_filterstr.bv_val,
-                                               op2.o_tmpmemctx );
-
                                        retry = 0;
                                        goto retry_add;
                                }