From: Howard Chu Date: Thu, 13 Mar 2008 07:30:56 +0000 (+0000) Subject: Fix prev commit, check for NULL syncCookie X-Git-Tag: OPENLDAP_REL_ENG_2_4_9~20^2~94 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e3849e1a9c71d9e917a7ab26a38611d15a74a2bb;p=openldap Fix prev commit, check for NULL syncCookie --- diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 11524882be..c11b15d6c0 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -596,27 +596,35 @@ do_syncrep1( * this particular consumer. That includes other consumers in * the same context, or local changes detected above. */ - if ( si->si_cookieAge != si->si_cookieState->cs_age ) { - for (i=0; !BER_BVISNULL( &si->si_syncCookie.ctxcsn[i] ); i++) { - /* bogus, just dup everything */ - if ( si->si_syncCookie.sids[i] == -1 ) { - ber_bvarray_free( si->si_syncCookie.ctxcsn ); - ber_bvarray_dup_x( &si->si_syncCookie.ctxcsn, - si->si_cookieState->cs_vals, NULL ); - changed = 1; - break; - } - for (j=0; jsi_cookieState->cs_num; j++) { - if ( si->si_syncCookie.sids[i] != - si->si_cookieState->cs_sids[j] ) - continue; - if ( bvmatch( &si->si_syncCookie.ctxcsn[i], - &si->si_cookieState->cs_vals[j] )) + if ( si->si_cookieState->cs_num > 0 && si->si_cookieAge != + si->si_cookieState->cs_age ) { + if ( !si->si_syncCookie.numcsns ) { + ber_bvarray_free( si->si_syncCookie.ctxcsn ); + ber_bvarray_dup_x( &si->si_syncCookie.ctxcsn, + si->si_cookieState->cs_vals, NULL ); + changed = 1; + } else { + for (i=0; !BER_BVISNULL( &si->si_syncCookie.ctxcsn[i] ); i++) { + /* bogus, just dup everything */ + if ( si->si_syncCookie.sids[i] == -1 ) { + ber_bvarray_free( si->si_syncCookie.ctxcsn ); + ber_bvarray_dup_x( &si->si_syncCookie.ctxcsn, + si->si_cookieState->cs_vals, NULL ); + changed = 1; break; - ber_bvreplace( &si->si_syncCookie.ctxcsn[i], - &si->si_cookieState->cs_vals[j] ); - changed = 1; - break; + } + for (j=0; jsi_cookieState->cs_num; j++) { + if ( si->si_syncCookie.sids[i] != + si->si_cookieState->cs_sids[j] ) + continue; + if ( bvmatch( &si->si_syncCookie.ctxcsn[i], + &si->si_cookieState->cs_vals[j] )) + break; + ber_bvreplace( &si->si_syncCookie.ctxcsn[i], + &si->si_cookieState->cs_vals[j] ); + changed = 1; + break; + } } } }