]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/syncrepl.c
ITS#8789 revert previous patch
[openldap] / servers / slapd / syncrepl.c
index 60e5e7c13e820d9ec963ffb8396adc9b76ec3ac8..36d01d85bf7d69d759ed39abef7ac73497ae4324 100644 (file)
@@ -152,7 +152,7 @@ static int syncrepl_entry(
                                        struct berval *cookieCSN );
 static int syncrepl_updateCookie(
                                        syncinfo_t *, Operation *,
-                                       struct sync_cookie * );
+                                       struct sync_cookie *, int save );
 static struct berval * slap_uuidstr_from_normalized(
                                        struct berval *, struct berval *, void * );
 static int syncrepl_add_glue_ancestors(
@@ -1029,7 +1029,7 @@ do_syncrep2(
                                if ( ( rc = syncrepl_message_to_op( si, op, msg ) ) == LDAP_SUCCESS &&
                                        syncCookie.ctxcsn )
                                {
-                                       rc = syncrepl_updateCookie( si, op, &syncCookie );
+                                       rc = syncrepl_updateCookie( si, op, &syncCookie, 0 );
                                } else switch ( rc ) {
                                        case LDAP_ALREADY_EXISTS:
                                        case LDAP_NO_SUCH_OBJECT:
@@ -1057,7 +1057,7 @@ do_syncrep2(
                                        syncstate, syncUUID, syncCookie.ctxcsn ) ) == LDAP_SUCCESS &&
                                        syncCookie.ctxcsn )
                                {
-                                       rc = syncrepl_updateCookie( si, op, &syncCookie );
+                                       rc = syncrepl_updateCookie( si, op, &syncCookie, 0 );
                                }
                        }
                        if ( punlock >= 0 ) {
@@ -1203,7 +1203,7 @@ do_syncrep2(
                        }
                        if ( syncCookie.ctxcsn && match < 0 && err == LDAP_SUCCESS )
                        {
-                               rc = syncrepl_updateCookie( si, op, &syncCookie );
+                               rc = syncrepl_updateCookie( si, op, &syncCookie, 1 );
                        }
                        if ( si->si_refreshCount ) {
                                LDAP_SLIST_REMOVE( &op->o_extra, si->si_refreshTxn, OpExtra, oe_next );
@@ -1393,7 +1393,7 @@ do_syncrep2(
 
                                        if ( syncCookie.ctxcsn )
                                        {
-                                               rc = syncrepl_updateCookie( si, op, &syncCookie);
+                                               rc = syncrepl_updateCookie( si, op, &syncCookie, 1 );
                                        }
                                        if ( si->si_presentlist ) {
                                                presentlist_free( si->si_presentlist );
@@ -3931,7 +3931,8 @@ static int
 syncrepl_updateCookie(
        syncinfo_t *si,
        Operation *op,
-       struct sync_cookie *syncCookie )
+       struct sync_cookie *syncCookie,
+       int save )
 {
        Backend *be = op->o_bd;
        Modifications mod;
@@ -4036,7 +4037,11 @@ syncrepl_updateCookie(
        op->o_req_ndn = si->si_contextdn;
 
        /* update contextCSN */
-       op->o_dont_replicate = 1;
+       op->o_dont_replicate = !save;
+
+       /* avoid timestamp collisions */
+       if ( save )
+               slap_op_time( &op->o_time, &op->o_tincr );
 
        mod.sml_numvals = sc.numcsns;
        mod.sml_values = sc.ctxcsn;
@@ -4053,6 +4058,8 @@ syncrepl_updateCookie(
                Entry *e = slap_create_context_csn_entry( op->o_bd, NULL );
                rs_reinit( &rs_modify, REP_RESULT );
                rc = slap_mods2entry( &mod, &e, 0, 1, &text, txtbuf, textlen);
+               slap_queue_csn( op, &first );
+               op->o_tag = LDAP_REQ_ADD;
                op->ora_e = e;
                rc = op->o_bd->be_add( op, &rs_modify );
                if ( e == op->ora_e )