]> git.sur5r.net Git - openldap/commitdiff
ITS#4622
authorHoward Chu <hyc@openldap.org>
Thu, 27 Jul 2006 10:44:22 +0000 (10:44 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 27 Jul 2006 10:44:22 +0000 (10:44 +0000)
  syncrepl: don't save contextCSN on incoming context entry
  syncprov: delete contextCSN on checkpoint if ctxcsn is empty

servers/slapd/overlays/syncprov.c
servers/slapd/syncrepl.c

index c9de4aec8ed9abc7c5a831fa6a38b45d3a754e16..271a48a672bef92bf36a534d73e5d5582267fde5 100644 (file)
@@ -1244,9 +1244,14 @@ syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on )
        struct berval bv[2];
        slap_callback cb = {0};
 
-       mod.sml_values = bv;
-       bv[1].bv_val = NULL;
-       bv[0] = si->si_ctxcsn;
+       /* If ctxcsn is empty, delete it */
+       if ( BER_BVISEMPTY( &si->si_ctxcsn )) {
+               mod.sml_values = NULL;
+       } else {
+               mod.sml_values = bv;
+               bv[1].bv_val = NULL;
+               bv[0] = si->si_ctxcsn;
+       }
        mod.sml_nvalues = NULL;
        mod.sml_desc = slap_schema.si_ad_contextCSN;
        mod.sml_op = LDAP_MOD_REPLACE;
@@ -2376,15 +2381,16 @@ syncprov_db_open(
                        ldap_pvt_thread_create( &tid, 0, syncprov_db_otask, op );
                        ldap_pvt_thread_join( tid, NULL );
                }
-       } else if ( SLAP_SYNC_SHADOW( op->o_bd )) {
-               /* If we're also a consumer, and we didn't find the context entry,
-                * then don't generate anything, wait for our provider to send it
-                * to us.
-                */
-               goto out;
        }
 
        if ( BER_BVISEMPTY( &si->si_ctxcsn ) ) {
+               if ( SLAP_SYNC_SHADOW( op->o_bd )) {
+               /* If we're also a consumer, and we didn't get a contextCSN,
+                * then don't generate anything, wait for our provider to send it
+                * to us.
+                */
+                       goto out;
+               }
                si->si_ctxcsn.bv_len = sizeof( si->si_ctxcsnbuf );
                slap_get_csn( op, &si->si_ctxcsn, 0 );
        }
index d0c94978cb9060de26ace7318601133a97650796..311acd85d04b2813ea081853f24be45a21402c14 100644 (file)
@@ -1769,6 +1769,22 @@ syncrepl_entry(
                        ber_memfree( a->a_vals[0].bv_val );
                        ber_dupbv( &a->a_vals[0], &syncUUID_strrep );
                }
+               /* Don't save the contextCSN on the inooming context entry,
+                * we'll write it when syncrepl_updateCookie eventually
+                * gets called. (ITS#4622)
+                */
+               if ( syncstate == LDAP_SYNC_ADD && dn_match( &entry->e_nname,
+                       &be->be_nsuffix[0] )) {
+                       Attribute **ap;
+                       for ( ap = &entry->e_attrs; *ap; ap=&(*ap)->a_next ) {
+                               a = *ap;
+                               if ( a->a_desc == slap_schema.si_ad_contextCSN ) {
+                                       *ap = a->a_next;
+                                       attr_free( a );
+                                       break;
+                               }
+                       }
+               }
        }
 
        slap_op_time( &op->o_time, &op->o_tincr );