]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/syncprov.c
More for prev commit - set entryCSN as well.
[openldap] / servers / slapd / overlays / syncprov.c
index 561b5b2fd1cc21ab353d410d90f865cca9b500c1..a62d0a0d0d8829ca15a8d54f9adcb78d6aafc56a 100644 (file)
@@ -450,12 +450,10 @@ syncprov_findbase( Operation *op, fbase_cookie *fc )
                case LDAP_SCOPE_SUBTREE:
                        fc->fscope = dnIsSuffix( fc->fdn, &fc->fss->s_base );
                        break;
-#ifdef LDAP_SCOPE_SUBORDINATE
                case LDAP_SCOPE_SUBORDINATE:
                        fc->fscope = dnIsSuffix( fc->fdn, &fc->fss->s_base ) &&
                                !dn_match( fc->fdn, &fc->fss->s_base );
                        break;
-#endif
                }
        }
 
@@ -483,9 +481,11 @@ syncprov_findbase( Operation *op, fbase_cookie *fc )
  * CSN, and generate Present records for them. We always collect this result
  * in SyncID sets, even if there's only one match.
  */
-#define        FIND_MAXCSN     1
-#define        FIND_CSN        2
-#define        FIND_PRESENT    3
+typedef enum find_csn_t {
+       FIND_MAXCSN     = 1,
+       FIND_CSN        = 2,
+       FIND_PRESENT    = 3
+} find_csn_t;
 
 static int
 findmax_cb( Operation *op, SlapReply *rs )
@@ -508,7 +508,11 @@ findcsn_cb( Operation *op, SlapReply *rs )
 {
        slap_callback *sc = op->o_callback;
 
-       if ( rs->sr_type == REP_SEARCH && rs->sr_err == LDAP_SUCCESS ) {
+       /* We just want to know that at least one exists, so it's OK if
+        * we exceed the unchecked limit.
+        */
+       if ( rs->sr_err == LDAP_ADMINLIMIT_EXCEEDED ||
+               (rs->sr_type == REP_SEARCH && rs->sr_err == LDAP_SUCCESS )) {
                sc->sc_private = (void *)1;
        }
        return LDAP_SUCCESS;
@@ -564,7 +568,7 @@ findpres_cb( Operation *op, SlapReply *rs )
 }
 
 static int
-syncprov_findcsn( Operation *op, int mode )
+syncprov_findcsn( Operation *op, find_csn_t mode )
 {
        slap_overinst           *on = (slap_overinst *)op->o_bd->bd_info;
        syncprov_info_t         *si = on->on_bi.bi_private;
@@ -581,10 +585,10 @@ syncprov_findcsn( Operation *op, int mode )
 #else
        AttributeAssertion eq = { NULL, BER_BVNULL };
 #endif
-       int i, rc = LDAP_SUCCESS;
        fpres_cookie pcookie;
        sync_control *srs = NULL;
-       int findcsn_retry = 1;
+       struct slap_limits_set fc_limits;
+       int i, rc = LDAP_SUCCESS, findcsn_retry = 1;
 
        if ( mode != FIND_MAXCSN ) {
                srs = op->o_controls[slap_cids.sc_LDAPsync];
@@ -635,6 +639,8 @@ again:
                /* On retry, look for <= */
                } else {
                        cf.f_choice = LDAP_FILTER_LE;
+                       fop.ors_limit = &fc_limits;
+                       fc_limits.lms_s_unchecked = 1;
                        fop.ors_filterstr.bv_len = sprintf( buf, "(entryCSN<=%s)",
                                cf.f_av_value.bv_val );
                }
@@ -1220,9 +1226,9 @@ syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on )
        syncprov_info_t         *si = on->on_bi.bi_private;
        Modifications mod;
        Operation opm;
+       SlapReply rsm = { 0 };
        struct berval bv[2];
        slap_callback cb = {0};
-       int manage = get_manageDSAit(op);
 
        mod.sml_values = bv;
        bv[1].bv_val = NULL;
@@ -1242,8 +1248,12 @@ syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on )
        opm.o_req_ndn = op->o_bd->be_nsuffix[0];
        opm.o_bd->bd_info = on->on_info->oi_orig;
        opm.o_managedsait = SLAP_CONTROL_NONCRITICAL;
-       opm.o_bd->be_modify( &opm, rs );
-       opm.o_managedsait = manage;
+       SLAP_DBFLAGS( opm.o_bd ) |= SLAP_DBFLAG_NOLASTMOD;
+       opm.o_bd->be_modify( &opm, &rsm );
+       SLAP_DBFLAGS( opm.o_bd ) ^= SLAP_DBFLAG_NOLASTMOD;
+       if ( mod.sml_next != NULL ) {
+               slap_mods_free( mod.sml_next, 1 );
+       }
 }
 
 static void
@@ -2183,8 +2193,31 @@ sp_cf_gen(ConfigArgs *c)
        }
        switch ( c->type ) {
        case SP_CHKPT:
-               si->si_chkops = atoi( c->argv[1] );
-               si->si_chktime = atoi( c->argv[2] ) * 60;
+               if ( lutil_atoi( &si->si_chkops, c->argv[1] ) != 0 ) {
+                       sprintf( c->msg, "%s unable to parse checkpoint ops # \"%s\"",
+                               c->argv[0], c->argv[1] );
+                       Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 );
+                       return ARG_BAD_CONF;
+               }
+               if ( si->si_chkops <= 0 ) {
+                       sprintf( c->msg, "%s invalid checkpoint ops # \"%d\"",
+                               c->argv[0], si->si_chkops );
+                       Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 );
+                       return ARG_BAD_CONF;
+               }
+               if ( lutil_atoi( &si->si_chktime, c->argv[2] ) != 0 ) {
+                       sprintf( c->msg, "%s unable to parse checkpoint time \"%s\"",
+                               c->argv[0], c->argv[1] );
+                       Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 );
+                       return ARG_BAD_CONF;
+               }
+               if ( si->si_chktime <= 0 ) {
+                       sprintf( c->msg, "%s invalid checkpoint time \"%d\"",
+                               c->argv[0], si->si_chkops );
+                       Debug( LDAP_DEBUG_CONFIG, "%s: %s\n", c->log, c->msg, 0 );
+                       return ARG_BAD_CONF;
+               }
+               si->si_chktime *= 60;
                break;
        case SP_SESSL: {
                sessionlog *sl;
@@ -2504,7 +2537,7 @@ static int syncprov_parseCtrl (
 static slap_overinst           syncprov;
 
 int
-syncprov_init()
+syncprov_initialize()
 {
        int rc;
 
@@ -2549,7 +2582,7 @@ syncprov_init()
 int
 init_module( int argc, char *argv[] )
 {
-       return syncprov_init();
+       return syncprov_initialize();
 }
 #endif /* SLAPD_OVER_SYNCPROV == SLAPD_MOD_DYNAMIC */