]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/syncprov.c
ITS#5705
[openldap] / servers / slapd / overlays / syncprov.c
index e6e2161e447abcc7d4c625ce29e7f44a45f56aba..db113f042be0ff142df37556fb467e8ef86027f3 100644 (file)
@@ -393,9 +393,6 @@ static struct berval generic_filterstr = BER_BVC("(objectclass=*)");
 static int
 syncprov_findbase( Operation *op, fbase_cookie *fc )
 {
-       opcookie *opc = op->o_callback->sc_private;
-       slap_overinst *on = opc->son;
-
        /* Use basic parameters from syncrepl search, but use
         * current op's threadctx / tmpmemctx
         */
@@ -630,7 +627,7 @@ again:
                cf.f_av_value = si->si_ctxcsn[maxid];
                fop.ors_filterstr.bv_len = snprintf( buf, sizeof( buf ),
                        "(entryCSN>=%s)", cf.f_av_value.bv_val );
-               if ( fop.ors_filterstr.bv_len < 0 || fop.ors_filterstr.bv_len >= sizeof( buf ) ) {
+               if ( fop.ors_filterstr.bv_len >= sizeof( buf ) ) {
                        return LDAP_OTHER;
                }
                fop.ors_attrsonly = 0;
@@ -667,7 +664,7 @@ again:
                        fop.ors_filterstr.bv_len = snprintf( buf, sizeof( buf ),
                                "(entryCSN<=%s)", cf.f_av_value.bv_val );
                }
-               if ( fop.ors_filterstr.bv_len < 0 || fop.ors_filterstr.bv_len >= sizeof( buf ) ) {
+               if ( fop.ors_filterstr.bv_len >= sizeof( buf ) ) {
                        return LDAP_OTHER;
                }
                fop.ors_attrsonly = 1;
@@ -1338,7 +1335,7 @@ syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on )
        mod.sml_nvalues = NULL;
        mod.sml_desc = slap_schema.si_ad_contextCSN;
        mod.sml_op = LDAP_MOD_REPLACE;
-       mod.sml_flags = 0;
+       mod.sml_flags = SLAP_MOD_INTERNAL;
        mod.sml_next = NULL;
 
        cb.sc_response = slap_null_cb;
@@ -1577,14 +1574,16 @@ syncprov_playlog( Operation *op, SlapReply *rs, sessionlog *sl,
                if ( delcsn[0].bv_len ) {
                        slap_compose_sync_cookie( op, &cookie, delcsn, srs->sr_state.rid,
                                srs->sr_state.sid );
-               }
 
-               Debug( LDAP_DEBUG_SYNC, "syncprov_playlog: cookie=%s\n", cookie.bv_val, 0, 0 );
+                       Debug( LDAP_DEBUG_SYNC, "syncprov_playlog: cookie=%s\n", cookie.bv_val, 0, 0 );
+               }
 
                uuids[ndel].bv_val = NULL;
                syncprov_sendinfo( op, rs, LDAP_TAG_SYNC_ID_SET,
                        delcsn[0].bv_len ? &cookie : NULL, 0, uuids, 1 );
-               op->o_tmpfree( cookie.bv_val, op->o_tmpmemctx );
+               if ( delcsn[0].bv_len ) {
+                       op->o_tmpfree( cookie.bv_val, op->o_tmpmemctx );
+               }
        }
        op->o_tmpfree( uuids, op->o_tmpmemctx );
 }
@@ -2323,6 +2322,15 @@ no_change:               if ( !(op->o_sync_mode & SLAP_SYNC_PERSIST) ) {
                                send_ldap_error( op, rs, LDAP_SYNC_REFRESH_REQUIRED, "sync cookie is stale" );
                                return rs->sr_err;
                        }
+                       if ( srs->sr_state.ctxcsn ) {
+                               ber_bvarray_free_x( srs->sr_state.ctxcsn, op->o_tmpmemctx );
+                               srs->sr_state.ctxcsn = NULL;
+                       }
+                       if ( srs->sr_state.sids ) {
+                               slap_sl_free( srs->sr_state.sids, op->o_tmpmemctx );
+                               srs->sr_state.sids = NULL;
+                       }
+                       srs->sr_state.numcsns = 0;
                } else {
                        gotstate = 1;
                        /* If changed and doing Present lookup, send Present UUIDs */
@@ -2501,7 +2509,11 @@ static ConfigOCs spocs[] = {
                "NAME 'olcSyncProvConfig' "
                "DESC 'SyncRepl Provider configuration' "
                "SUP olcOverlayConfig "
-               "MAY ( olcSpCheckpoint $ olcSpSessionlog $ olcSpNoPresent ) )",
+               "MAY ( olcSpCheckpoint "
+                       "$ olcSpSessionlog "
+                       "$ olcSpNoPresent "
+                       "$ olcSpReloadHint "
+               ") )",
                        Cft_Overlay, spcfg },
        { NULL, 0, NULL }
 };
@@ -2520,7 +2532,7 @@ sp_cf_gen(ConfigArgs *c)
                                struct berval bv;
                                bv.bv_len = snprintf( c->cr_msg, sizeof( c->cr_msg ),
                                        "%d %d", si->si_chkops, si->si_chktime );
-                               if ( bv.bv_len < 0 || bv.bv_len >= sizeof( c->cr_msg ) ) {
+                               if ( bv.bv_len >= sizeof( c->cr_msg ) ) {
                                        rc = 1;
                                } else {
                                        bv.bv_val = c->cr_msg;