From 559b7464376c3d7edd74c0948793352912c06f2c Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 1 Sep 2004 04:18:56 +0000 Subject: [PATCH] Avoid gratuitous reindexing of cn and objectclass in syncrepl_updateCookie --- servers/slapd/syncrepl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 557ab5b567..91a57feba7 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -1762,21 +1762,24 @@ syncrepl_updateCookie( *modtail = mod; modtail = &mod->sml_next; - if ( scbva[0].bv_val ) ch_free( scbva[0].bv_val ); - ber_dupbv( &scbva[0], &si->si_syncCookie.octet_str[0] ); mod = (Modifications *) ch_calloc( 1, sizeof( Modifications )); mod->sml_op = LDAP_MOD_REPLACE; - mod->sml_desc = slap_schema.si_ad_syncreplCookie; + mod->sml_desc = slap_schema.si_ad_subtreeSpecification; mod->sml_type = mod->sml_desc->ad_cname; - mod->sml_values = scbva; + mod->sml_values = ssbva; *modtail = mod; modtail = &mod->sml_next; + /* Keep this last, so we can avoid touching the previous + * attributes unnecessarily. + */ + if ( scbva[0].bv_val ) ch_free( scbva[0].bv_val ); + ber_dupbv( &scbva[0], &si->si_syncCookie.octet_str[0] ); mod = (Modifications *) ch_calloc( 1, sizeof( Modifications )); mod->sml_op = LDAP_MOD_REPLACE; - mod->sml_desc = slap_schema.si_ad_subtreeSpecification; + mod->sml_desc = slap_schema.si_ad_syncreplCookie; mod->sml_type = mod->sml_desc->ad_cname; - mod->sml_values = ssbva; + mod->sml_values = scbva; *modtail = mod; modtail = &mod->sml_next; @@ -1841,7 +1844,8 @@ syncrepl_updateCookie( /* update persistent cookie */ update_cookie_retry: op->o_tag = LDAP_REQ_MODIFY; - op->orm_modlist = modlist; + /* Just modify the cookie value, not the entire entry */ + op->orm_modlist = mod; rc = be->be_modify( op, &rs_modify ); if ( rs_modify.sr_err != LDAP_SUCCESS ) { -- 2.39.5