]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#8102, #9330 partially revert
authorHoward Chu <hyc@openldap.org>
Thu, 10 Sep 2020 14:15:52 +0000 (15:15 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Thu, 10 Sep 2020 17:13:13 +0000 (17:13 +0000)
Fix a regression in delta-sync, was returning error on old
CSNs instead of ignoring them

servers/slapd/syncrepl.c

index 040bd06375fd33784448b7cd8b964ff19860791d..3040858adf5197bfa19cc88c6d0ee74296540a41 100644 (file)
@@ -2226,6 +2226,20 @@ syncrepl_op_modify( Operation *op, SlapReply *rs )
        if ( !mod )
                return SLAP_CB_CONTINUE;
 
+       {
+               int sid = slap_parse_csn_sid( &mod->sml_nvalues[0] );
+               ldap_pvt_thread_mutex_lock( &si->si_cookieState->cs_mutex );
+               rc = check_csn_age( si, &op->o_req_dn, &mod->sml_nvalues[0],
+                       sid, (cookie_vals *)&si->si_cookieState->cs_vals, NULL );
+               ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );
+               if ( rc == CV_CSN_OLD ) {
+                       slap_graduate_commit_csn( op );
+                       /* tell accesslog this was a failure */
+                       rs->sr_err = LDAP_TYPE_OR_VALUE_EXISTS;
+                       return LDAP_SUCCESS;
+               }
+       }
+
        rc = overlay_entry_get_ov( op, &op->o_req_ndn, NULL, NULL, 0, &e, on );
        if ( rc == 0 ) {
                Attribute *a;
@@ -2413,14 +2427,12 @@ syncrepl_message_to_op(
        const char      *text;
        char txtbuf[SLAP_TEXT_BUFLEN];
        size_t textlen = sizeof txtbuf;
-       char csnbuf[LDAP_PVT_CSNSTR_BUFSIZE];
 
        struct berval   bdn, dn = BER_BVNULL, ndn;
        struct berval   bv, bv2, *bvals = NULL;
        struct berval   rdn = BER_BVNULL, sup = BER_BVNULL,
                prdn = BER_BVNULL, nrdn = BER_BVNULL,
                psup = BER_BVNULL, nsup = BER_BVNULL;
-       struct berval   csn = {0, csnbuf};
        int             rc, deleteOldRdn = 0, freeReqDn = 0;
        int             do_graduate = 0, do_unlock = 0;
 
@@ -2523,13 +2535,8 @@ syncrepl_message_to_op(
                } else if ( !ber_bvstrcasecmp( &bv,
                        &slap_schema.si_ad_entryCSN->ad_cname ) )
                {
-                       int len = bvals->bv_len;
-                       if ( bvals->bv_len >= sizeof(csnbuf) )
-                               csn.bv_len = sizeof(csnbuf) - 1;
-                       else
-                               csn.bv_len = bvals->bv_len;
-                       AC_MEMCPY( csn.bv_val, bvals->bv_val, csn.bv_len );
-                       csn.bv_val[csn.bv_len] = '\0';
+                       slap_queue_csn( op, bvals );
+                       do_graduate = 1;
                }
                ch_free( bvals );
        }
@@ -2545,19 +2552,6 @@ syncrepl_message_to_op(
                        goto done;
                do_unlock = 1;
        }
-       if ( csn.bv_len ) {
-               int i, sid = slap_parse_csn_sid( &csn );
-               ldap_pvt_thread_mutex_lock( &si->si_cookieState->cs_mutex );
-               i = check_csn_age( si, &bdn, &csn, sid, (cookie_vals *)&si->si_cookieState->cs_vals, NULL );
-               ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );
-               if ( i == CV_CSN_OLD ) {
-                       /* skip this op */
-                       rc = -1;
-                       goto done;
-               }
-               slap_queue_csn( op, &csn );
-               do_graduate = 1;
-       }
 
        op->o_callback = &cb;
        slap_op_time( &op->o_time, &op->o_tincr );