]> git.sur5r.net Git - openldap/commitdiff
Revert 1.447 ITS#5793, slap_queue_csn is mandatory
authorHoward Chu <hyc@openldap.org>
Thu, 12 Mar 2009 13:50:51 +0000 (13:50 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 12 Mar 2009 13:50:51 +0000 (13:50 +0000)
servers/slapd/syncrepl.c

index ad38463a6261cc7cf2d6d5d52a334c01d664d92a..111a427b774b5c1552e918c7cdef7edc899b214b 100644 (file)
@@ -2898,11 +2898,12 @@ syncrepl_updateCookie(
 {
        Backend *be = op->o_bd;
        Modifications mod;
+       struct berval first = BER_BVNULL;
 #ifdef CHECK_CSN
        Syntax *syn = slap_schema.si_ad_contextCSN->ad_type->sat_syntax;
 #endif
 
-       int rc, i, j, csn_changed = 0;
+       int rc, i, j;
        ber_len_t len;
 
        slap_callback cb = { NULL };
@@ -2944,7 +2945,13 @@ syncrepl_updateCookie(
                        if ( memcmp( syncCookie->ctxcsn[i].bv_val,
                                si->si_cookieState->cs_vals[j].bv_val, len ) > 0 ) {
                                mod.sml_values[j] = syncCookie->ctxcsn[i];
-                               csn_changed = 1;
+                               if ( BER_BVISNULL( &first ) ) {
+                                       first = syncCookie->ctxcsn[i];
+
+                               } else if ( memcmp( syncCookie->ctxcsn[i].bv_val, first.bv_val, first.bv_len ) > 0 )
+                               {
+                                       first = syncCookie->ctxcsn[i];
+                               }
                        }
                        break;
                }
@@ -2954,16 +2961,23 @@ syncrepl_updateCookie(
                                ( mod.sml_numvals+2 )*sizeof(struct berval), op->o_tmpmemctx );
                        mod.sml_values[mod.sml_numvals++] = syncCookie->ctxcsn[i];
                        BER_BVZERO( &mod.sml_values[mod.sml_numvals] );
-                       csn_changed = 1;
+                       if ( BER_BVISNULL( &first ) ) {
+                               first = syncCookie->ctxcsn[i];
+                       } else if ( memcmp( syncCookie->ctxcsn[i].bv_val, first.bv_val, first.bv_len ) > 0 )
+                       {
+                               first = syncCookie->ctxcsn[i];
+                       }
                }
        }
        /* Should never happen, ITS#5065 */
-       if ( !csn_changed ) {
+       if ( BER_BVISNULL( &first )) {
                ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );
                op->o_tmpfree( mod.sml_values, op->o_tmpmemctx );
                return 0;
        }
        op->o_bd = si->si_wbe;
+       slap_queue_csn( op, &first );
+
        op->o_tag = LDAP_REQ_MODIFY;
 
        cb.sc_response = null_callback;