]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/search.c
Sync with HEAD
[openldap] / servers / slapd / back-bdb / search.c
index 7223daecc0208fdd88450d359a9a3b1ad5ab2d72..ca4b755e2cb26cc30123d2b5d883c2acd3336cc2 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2003 The OpenLDAP Foundation.
+ * Copyright 2000-2004 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -282,7 +282,7 @@ nextido:
                ei = NULL;
                rs->sr_err = bdb_cache_find_id(op, NULL, ido, &ei,
                        0, locker, &locka );
-               if (rs->sr_err != LDAP_SUCCESS) goto nextido;
+               if ( rs->sr_err != LDAP_SUCCESS ) goto nextido;
                e = ei->bei_e;
        }
        return rs->sr_err;
@@ -459,12 +459,13 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop,
                        if ( ps_list->o_sync_slog_omitcsn.bv_len != 0 ) {
                                mr = slap_schema.si_ad_entryCSN->ad_type->sat_ordering;
                                if ( sop->o_sync_state.ctxcsn &&
-                                        sop->o_sync_state.ctxcsn->bv_val != NULL ) {
-                                        value_match( &match, slap_schema.si_ad_entryCSN, mr,
-                                                               SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
-                                                               sop->o_sync_state.ctxcsn,
-                                                               &ps_list->o_sync_slog_omitcsn,
-                                                               &text );
+                                       sop->o_sync_state.ctxcsn->bv_val != NULL )
+                               {
+                                       value_match( &match, slap_schema.si_ad_entryCSN, mr,
+                                               SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
+                                               sop->o_sync_state.ctxcsn,
+                                               &ps_list->o_sync_slog_omitcsn,
+                                               &text );
                                } else {
                                        match = -1;
                                }
@@ -505,7 +506,6 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop,
        manageDSAit = get_manageDSAit( sop );
 
        /* Sync control overrides manageDSAit */
-
        if ( !IS_PSEARCH && sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
                if ( manageDSAit == SLAP_NO_CONTROL ) {
                        manageDSAit = SLAP_CRITICAL_CONTROL;
@@ -516,7 +516,7 @@ bdb_do_search( Operation *op, SlapReply *rs, Operation *sop,
                }
        }
 
-       rs->sr_err = LOCK_ID (bdb->bi_dbenv, &locker );
+       rs->sr_err = LOCK_IDbdb->bi_dbenv, &locker );
 
        switch(rs->sr_err) {
        case 0:
@@ -605,7 +605,7 @@ dn2entry_retry:
                return rs->sr_err;
        }
 
-       if (!manageDSAit && e != &slap_entry_root && is_entry_referral( e ) ) {
+       if ( !manageDSAit && e != &slap_entry_root && is_entry_referral( e ) ) {
                /* entry is a referral, don't allow add */
                struct berval matched_dn;
                BerVarray erefs;
@@ -655,12 +655,13 @@ dn2entry_retry:
        if ( be_isroot( op->o_bd, &sop->o_ndn ) ) {
                isroot = 1;
        } else {
-               ( void ) get_limits( op->o_bd, &sop->o_ndn, &limit );
+               ( void ) get_limits( op, &sop->o_ndn, &limit );
        }
 
        /* The time/size limits come first because they require very little
         * effort, so there's no chance the candidates are selected and then 
-        * the request is not honored only because of time/size constraints */
+        * the request is not honored only because of time/size constraints
+        */
 
        /* if no time limit requested, use soft limit (unless root!) */
        if ( isroot ) {
@@ -775,10 +776,8 @@ dn2entry_retry:
                        locker, candidates, scopes );
        }
 
-       if ( !IS_PSEARCH ) {
-               if ( sop->o_sync_mode != SLAP_SYNC_NONE ) {
-                       bdb_cache_entry_db_unlock( bdb->bi_dbenv, &ctxcsn_lock );
-               }
+       if ( !IS_PSEARCH && sop->o_sync_mode != SLAP_SYNC_NONE ) {
+               bdb_cache_entry_db_unlock( bdb->bi_dbenv, &ctxcsn_lock );
        }
 
        /* start cursor at beginning of candidates.
@@ -791,12 +790,11 @@ dn2entry_retry:
                                rs->sr_err = LDAP_SUCCESS;
                                goto done;
                        }
-               } else {
-                       if ( ps_e->e_id < BDB_IDL_RANGE_FIRST(candidates)
-                          || ps_e->e_id > BDB_IDL_RANGE_LAST(candidates)){
-                               rs->sr_err = LDAP_SUCCESS;
-                               goto done;
-                       }
+               } else if ( ps_e->e_id < BDB_IDL_RANGE_FIRST( candidates ) ||
+                       ps_e->e_id > BDB_IDL_RANGE_LAST( candidates ))
+               {
+                       rs->sr_err = LDAP_SUCCESS;
+                       goto done;
                }
                candidates[0] = 1;
                candidates[1] = ps_e->e_id;
@@ -811,10 +809,7 @@ dn2entry_retry:
                        0, 0, 0 );
 #endif
 
-               rs->sr_err = LDAP_SUCCESS;
-               rs->sr_entry = NULL;
-               send_ldap_result( sop, rs );
-               goto done;
+               goto nochange;
        }
 
        /* if not root and candidates exceed to-be-checked entries, abort */
@@ -843,7 +838,7 @@ dn2entry_retry:
                        }
                        for ( id = bdb_idl_first( candidates, &cursor );
                                id != NOID && id <= (ID)( sop->o_pagedresults_state.ps_cookie );
-                               id = bdb_idl_next( candidates, &cursor ) );
+                               id = bdb_idl_next( candidates, &cursor ) ) /* empty */;
                }
                if ( cursor == NOID ) {
 #ifdef NEW_LOGGING
@@ -863,7 +858,7 @@ dn2entry_retry:
                goto loop_begin;
        }
 
-       if ( (sop->o_sync_mode & SLAP_SYNC_REFRESH) || IS_PSEARCH ) {
+       if (( sop->o_sync_mode & SLAP_SYNC_REFRESH ) || IS_PSEARCH ) {
                int match;
 
                cookief.f_choice = LDAP_FILTER_AND;
@@ -960,7 +955,6 @@ loop_begin:
                        goto done;
                }
 
-
                if (!IS_PSEARCH) {
 id2entry_retry:
                        /* get the entry with reader lock */
@@ -1006,6 +1000,7 @@ id2entry_retry:
                }
 
                rs->sr_entry = e;
+
 #ifdef BDB_SUBENTRIES
                /* FIXME: send all but syncrepl */
 #if 0
@@ -1054,9 +1049,8 @@ id2entry_retry:
 
                case LDAP_SCOPE_SUBTREE: {
                        EntryInfo *tmp;
-                       for ( tmp = BEI(e); tmp->bei_parent;
-                               tmp = tmp->bei_parent )
-                       {
+                       for (tmp = BEI(e); tmp->bei_parent;
+                                tmp = tmp->bei_parent ) {
                                if ( tmp->bei_id == base.e_id ) {
                                        scopeok = 1;
                                        break;