]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9282 Do not resuscitate entries we already deleted
authorOndřej Kuzník <ondra@mistotebe.net>
Mon, 11 Oct 2021 13:17:15 +0000 (14:17 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Mon, 13 Dec 2021 16:40:50 +0000 (16:40 +0000)
servers/slapd/syncrepl.c

index 5e491e690e3b923b47dbc5d9c5641bb7a7af51a0..b4a8f496a9b2dae0403b5b372fe8df728aac327d 100644 (file)
@@ -4079,6 +4079,25 @@ syncrepl_entry(
                        }
                }
 retry_add:;
+               if ( !BER_BVISNULL( &op->o_csn ) ) {
+                       /* Check we're not covered by current contextCSN */
+                       int i, sid = slap_parse_csn_sid( &op->o_csn );
+                       ldap_pvt_thread_mutex_lock( &si->si_cookieState->cs_mutex );
+                       for ( i=0;
+                               i < si->si_cookieState->cs_num &&
+                                       sid <= si->si_cookieState->cs_sids[i];
+                               i++ ) {
+                               if ( si->si_cookieState->cs_sids[i] == sid &&
+                                       ber_bvcmp( &op->o_csn, &si->si_cookieState->cs_vals[i] ) <= 0 ) {
+                                       Debug( LDAP_DEBUG_SYNC, "syncrepl_entry: %s "
+                                               "entry '%s' csn=%s not new enough, ignored\n",
+                                               si->si_ridtxt, entry->e_name.bv_val, op->o_csn.bv_val );
+                                       ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );
+                                       goto done;
+                               }
+                       }
+                       ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );
+               }
                if ( BER_BVISNULL( &dni.dn ) ) {
                        SlapReply       rs_add = {REP_RESULT};