From 55b29bedf8b7b04cd5980364782f6db39b6507ae Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 5 Feb 2007 09:19:46 +0000 Subject: [PATCH] Fix prev commit, don't generate a new ctxcsn if we're a consumer with an empty DB --- servers/slapd/overlays/syncprov.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/servers/slapd/overlays/syncprov.c b/servers/slapd/overlays/syncprov.c index c7ad1417b8..b6b7eb45b3 100644 --- a/servers/slapd/overlays/syncprov.c +++ b/servers/slapd/overlays/syncprov.c @@ -2061,11 +2061,16 @@ syncprov_op_search( Operation *op, SlapReply *rs ) /* snapshot the ctxcsn */ ldap_pvt_thread_mutex_lock( &si->si_csn_mutex ); - ber_bvarray_dup_x( &ctxcsn, si->si_ctxcsn, op->o_tmpmemctx ); numcsns = si->si_numcsns; - sids = op->o_tmpalloc( numcsns * sizeof(int), op->o_tmpmemctx ); - for ( i=0; isi_sids[i]; + if ( numcsns ) { + ber_bvarray_dup_x( &ctxcsn, si->si_ctxcsn, op->o_tmpmemctx ); + sids = op->o_tmpalloc( numcsns * sizeof(int), op->o_tmpmemctx ); + for ( i=0; isi_sids[i]; + } else { + ctxcsn = NULL; + sids = NULL; + } ldap_pvt_thread_mutex_unlock( &si->si_csn_mutex ); /* If we have a cookie, handle the PRESENT lookups */ @@ -2073,6 +2078,12 @@ syncprov_op_search( Operation *op, SlapReply *rs ) sessionlog *sl; int i, j; + /* If we don't have any CSN of our own yet, pretend nothing + * has changed. + */ + if ( !numcsns ) + goto no_change; + /* If there are SIDs we don't recognize in the cookie, drop them */ for (i=0; isr_state.numcsns; ) { for (j=0; jo_sync_mode & SLAP_SYNC_PERSIST) ) { LDAPControl *ctrls[2]; @@ -2534,10 +2545,10 @@ syncprov_db_open( char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ]; struct berval csn; - if ( SLAP_SYNC_SHADOW( op->o_bd ) && SLAP_SINGLE_SHADOW( op->o_bd )) { - /* If we're also a consumer, and we're not multimaster, - * then don't generate anything, wait for our provider to send it - * to us. + if ( SLAP_SYNC_SHADOW( op->o_bd )) { + /* If we're also a consumer, then don't generate anything. + * Wait for our provider to send it to us, or for a local + * modify if we have multimaster. */ goto out; } -- 2.39.5