]> git.sur5r.net Git - openldap/commitdiff
misc cleanup
authorPierangelo Masarati <ando@openldap.org>
Wed, 31 May 2006 14:11:07 +0000 (14:11 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 31 May 2006 14:11:07 +0000 (14:11 +0000)
servers/slapd/back-meta/back-meta.h
servers/slapd/back-meta/candidates.c
servers/slapd/back-meta/conn.c
servers/slapd/back-meta/search.c

index c12067292ffd4bc5a344a59f833bcaf33f3e90e4..0a33025a44cab4af7fc2966d6e3824f9a2c0c9f9 100644 (file)
@@ -427,9 +427,7 @@ meta_back_conndn_dup(
  */
 extern int
 meta_back_is_candidate(
-       struct berval           *nsuffix,
-       int                     suffixscope,
-       BerVarray               subtree_exclude,
+       metatarget_t            *mt,
        struct berval           *ndn,
        int                     scope );
 
index 27d3c2eaa16f4a6b0b5f280df29ce98ff92bad6b..f16a9d0edaabf07e86d9d7456e161fd150ba4467 100644 (file)
  */
 int 
 meta_back_is_candidate(
-       struct berval   *nsuffix,
-       int             suffixscope,
-       BerVarray       subtree_exclude,
+       metatarget_t    *mt,
        struct berval   *ndn,
        int             scope )
 {
-       if ( dnIsSuffix( ndn, nsuffix ) ) {
-               if ( subtree_exclude ) {
+       if ( dnIsSuffix( ndn, &mt->mt_nsuffix ) ) {
+               if ( mt->mt_subtree_exclude ) {
                        int     i;
 
-                       for ( i = 0; !BER_BVISNULL( &subtree_exclude[ i ] ); i++ ) {
-                               if ( dnIsSuffix( ndn, &subtree_exclude[ i ] ) ) {
+                       for ( i = 0; !BER_BVISNULL( &mt->mt_subtree_exclude[ i ] ); i++ ) {
+                               if ( dnIsSuffix( ndn, &mt->mt_subtree_exclude[ i ] ) ) {
                                        return META_NOT_CANDIDATE;
                                }
                        }
                }
 
-               switch ( suffixscope ) {
+               switch ( mt->mt_scope ) {
                case LDAP_SCOPE_SUBTREE:
                default:
                        return META_CANDIDATE;
 
                case LDAP_SCOPE_SUBORDINATE:
-                       if ( ndn->bv_len > nsuffix->bv_len ) {
+                       if ( ndn->bv_len > mt->mt_nsuffix.bv_len ) {
                                return META_CANDIDATE;
                        }
                        break;
 
                /* nearly useless; not allowed by config */
                case LDAP_SCOPE_ONELEVEL:
-                       if ( ndn->bv_len > nsuffix->bv_len ) {
+                       if ( ndn->bv_len > mt->mt_nsuffix.bv_len ) {
                                struct berval   rdn = *ndn;
 
-                               rdn.bv_len -= nsuffix->bv_len
+                               rdn.bv_len -= mt->mt_nsuffix.bv_len
                                        + STRLENOF( "," );
                                if ( dnIsOneLevelRDN( &rdn ) ) {
                                        return META_CANDIDATE;
@@ -102,7 +100,7 @@ meta_back_is_candidate(
 
                /* nearly useless; not allowed by config */
                case LDAP_SCOPE_BASE:
-                       if ( ndn->bv_len == nsuffix->bv_len ) {
+                       if ( ndn->bv_len == mt->mt_nsuffix.bv_len ) {
                                return META_CANDIDATE;
                        }
                        break;
@@ -111,7 +109,7 @@ meta_back_is_candidate(
                return META_NOT_CANDIDATE;
        }
 
-       if ( scope == LDAP_SCOPE_SUBTREE && dnIsSuffix( nsuffix, ndn ) ) {
+       if ( scope == LDAP_SCOPE_SUBTREE && dnIsSuffix( &mt->mt_nsuffix, ndn ) ) {
                /*
                 * suffix longer than dn, but common part matches
                 */
@@ -139,11 +137,7 @@ meta_back_select_unique_candidate(
        for ( i = 0; i < mi->mi_ntargets; i++ ) {
                metatarget_t    *mt = mi->mi_targets[ i ];
 
-               if ( meta_back_is_candidate( &mt->mt_nsuffix,
-                               mt->mt_scope,
-                               mt->mt_subtree_exclude,
-                               ndn, LDAP_SCOPE_BASE ) )
-               {
+               if ( meta_back_is_candidate( mt, ndn, LDAP_SCOPE_BASE ) ) {
                        if ( candidate == META_TARGET_NONE ) {
                                candidate = i;
 
index d1300d8f1c5db68206a8d04dc43c5e6a8ed94fa4..01d8fad38205b3b029831520ea2c09190b179a02 100644 (file)
@@ -719,9 +719,7 @@ meta_back_get_candidate(
                         * and a default target is defined, and it is
                         * a candidate, try using it (FIXME: YMMV) */
                        if ( mi->mi_defaulttarget != META_DEFAULT_TARGET_NONE
-                               && meta_back_is_candidate( &mi->mi_targets[ mi->mi_defaulttarget ]->mt_nsuffix,
-                                               mi->mi_targets[ mi->mi_defaulttarget ]->mt_scope,
-                                               mi->mi_targets[ mi->mi_defaulttarget ]->mt_subtree_exclude,
+                               && meta_back_is_candidate( mi->mi_targets[ mi->mi_defaulttarget ],
                                                ndn, op->o_tag == LDAP_REQ_SEARCH ? op->ors_scope : LDAP_SCOPE_BASE ) )
                        {
                                candidate = mi->mi_defaulttarget;
@@ -1181,11 +1179,8 @@ retry_lock2:;
                        metasingleconn_t        *msc = &mc->mc_conns[ i ];
 
                        if ( i == cached 
-                               || meta_back_is_candidate( &mt->mt_nsuffix,
-                                               mt->mt_scope,
-                                               mt->mt_subtree_exclude,
-                                               &op->o_req_ndn,
-                                               LDAP_SCOPE_SUBTREE ) )
+                               || meta_back_is_candidate( mt, &op->o_req_ndn,
+                                       LDAP_SCOPE_SUBTREE ) )
                        {
 
                                /*
index 23925647ac7fc1003924a0820003959508a160f6..97d0ff58ef83f78a97ea89e394d5918a23b1ccc3 100644 (file)
@@ -235,11 +235,9 @@ meta_back_search_start(
 {
        metainfo_t              *mi = ( metainfo_t * )op->o_bd->be_private;
        metatarget_t            *mt = mi->mi_targets[ candidate ];
-       metaconn_t              *mc = *mcp;
-       metasingleconn_t        *msc = &mc->mc_conns[ candidate ];
+       metasingleconn_t        *msc = &(*mcp)->mc_conns[ candidate ];
        struct berval           realbase = op->o_req_dn;
        int                     realscope = op->ors_scope;
-       ber_len_t               suffixlen = 0;
        struct berval           mbase = BER_BVNULL; 
        struct berval           mfilter = BER_BVNULL;
        char                    **mapped_attrs = NULL;
@@ -250,26 +248,10 @@ meta_back_search_start(
 
        Debug( LDAP_DEBUG_TRACE, "%s >>> meta_back_search_start[%d]\n", op->o_log_prefix, candidate, 0 );
 
-       /* should we check return values? */
-       if ( op->ors_deref != -1 ) {
-               assert( msc->msc_ld != NULL );
-               (void)ldap_set_option( msc->msc_ld, LDAP_OPT_DEREF,
-                               ( void * )&op->ors_deref );
-       }
-
-       if ( op->ors_tlimit != SLAP_NO_LIMIT ) {
-               tv.tv_sec = op->ors_tlimit > 0 ? op->ors_tlimit : 1;
-               tv.tv_usec = 0;
-               tvp = &tv;
-       }
-
-       dc->target = mt;
-
        /*
         * modifies the base according to the scope, if required
         */
-       suffixlen = mt->mt_nsuffix.bv_len;
-       if ( suffixlen > op->o_req_ndn.bv_len ) {
+       if ( mt->mt_nsuffix.bv_len > op->o_req_ndn.bv_len ) {
                switch ( op->ors_scope ) {
                case LDAP_SCOPE_SUBTREE:
                        /*
@@ -341,6 +323,7 @@ meta_back_search_start(
        /*
         * Rewrite the search base, if required
         */
+       dc->target = mt;
        dc->ctx = "searchBase";
        switch ( ldap_back_dn_massage( dc, &realbase, &mbase ) ) {
        default:
@@ -391,6 +374,19 @@ meta_back_search_start(
                goto done;
        }
 
+       /* should we check return values? */
+       if ( op->ors_deref != -1 ) {
+               assert( msc->msc_ld != NULL );
+               (void)ldap_set_option( msc->msc_ld, LDAP_OPT_DEREF,
+                               ( void * )&op->ors_deref );
+       }
+
+       if ( op->ors_tlimit != SLAP_NO_LIMIT ) {
+               tv.tv_sec = op->ors_tlimit > 0 ? op->ors_tlimit : 1;
+               tv.tv_usec = 0;
+               tvp = &tv;
+       }
+
        /*
         * Starts the search
         */