]> git.sur5r.net Git - openldap/commitdiff
Fix prev commit, check for NULL syncCookie
authorHoward Chu <hyc@openldap.org>
Thu, 13 Mar 2008 07:30:56 +0000 (07:30 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 13 Mar 2008 07:30:56 +0000 (07:30 +0000)
servers/slapd/syncrepl.c

index 11524882be71a88f9bde35104d05815825464b3a..c11b15d6c09f2bfffad4fb46c3ba8422fb666dcf 100644 (file)
@@ -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; j<si->si_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; j<si->si_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;
+                                       }
                                }
                        }
                }