]> git.sur5r.net Git - openldap/commitdiff
ITS#7473 check DN scope before fetching id2e
authorHoward Chu <hyc@openldap.org>
Fri, 11 Jan 2013 11:15:59 +0000 (03:15 -0800)
committerHoward Chu <hyc@openldap.org>
Fri, 11 Jan 2013 11:15:59 +0000 (03:15 -0800)
This is only a 10% gain, but still worth having for now.

servers/slapd/back-mdb/dn2id.c
servers/slapd/back-mdb/search.c

index c26e5778945d07655a53deeee472f1f18ad51d69..b1aec3b5946362900dfd7009eb7a0bf0bdbd4497 100644 (file)
@@ -616,7 +616,7 @@ mdb_idscopes(
                        key.mv_data = &id;
                        rc = mdb_cursor_get( isc->mc, &key, &data, MDB_SET );
                        if ( rc )
-                               break;
+                               return rc;
 
                        /* save RDN info */
                }
@@ -649,5 +649,5 @@ mdb_idscopes(
                if ( op->ors_scope == LDAP_SCOPE_ONELEVEL )
                        break;
        }
-       return MDB_NOTFOUND;
+       return MDB_SUCCESS;
 }
index 580aa8972d3571076beb9125e88079f247f932f0..d129b9c1c2461c7ad990565de57608c8dc0f6e59 100644 (file)
@@ -634,42 +634,6 @@ loop_begin:
                        goto done;
                }
 
-               if ( id == base->e_id ) {
-                       e = base;
-               } else {
-
-                       /* get the entry */
-                       rs->sr_err = mdb_id2edata( op, mci, id, &edata );
-                       if ( rs->sr_err == MDB_NOTFOUND ) {
-                               if( !MDB_IDL_IS_RANGE(candidates) ) {
-                                       /* only complain for non-range IDLs */
-                                       Debug( LDAP_DEBUG_TRACE,
-                                               LDAP_XSTRING(mdb_search)
-                                               ": candidate %ld not found\n",
-                                               (long) id, 0, 0 );
-                               } else {
-                                       /* get the next ID from the DB */
-                                       rs->sr_err = mdb_get_nextid( mci, &cursor );
-                                       if ( rs->sr_err == MDB_NOTFOUND ) {
-                                               break;
-                                       }
-                                       if ( rs->sr_err ) {
-                                               rs->sr_err = LDAP_OTHER;
-                                               rs->sr_text = "internal error in get_nextid";
-                                               send_ldap_result( op, rs );
-                                               goto done;
-                                       }
-                                       cursor--;
-                               }
-
-                               goto loop_continue;
-                       } else if ( rs->sr_err ) {
-                               rs->sr_err = LDAP_OTHER;
-                               rs->sr_text = "internal error in mdb_id2edata";
-                               send_ldap_result( op, rs );
-                               goto done;
-                       }
-               }
 
                /* Does this candidate actually satisfy the search scope?
                 */
@@ -694,7 +658,15 @@ loop_begin:
                        /* Fall-thru */
                case LDAP_SCOPE_ONELEVEL:
                        isc.id = id;
-                       if ( mdb_idscopes( op, &isc ) == MDB_SUCCESS ) scopeok = 1;
+                       isc.nscope = 0;
+                       rs->sr_err = mdb_idscopes( op, &isc );
+                       if ( rs->sr_err == MDB_SUCCESS ) {
+                               if ( isc.nscope )
+                                       scopeok = 1;
+                       } else {
+                               if ( rs->sr_err == MDB_NOTFOUND )
+                                       goto notfound;
+                       }
                        break;
                }
 
@@ -708,7 +680,43 @@ loop_begin:
                        goto loop_continue;
                }
 
-               if ( id != base->e_id ) {
+               if ( id == base->e_id ) {
+                       e = base;
+               } else {
+
+                       /* get the entry */
+                       rs->sr_err = mdb_id2edata( op, mci, id, &edata );
+                       if ( rs->sr_err == MDB_NOTFOUND ) {
+notfound:
+                               if( !MDB_IDL_IS_RANGE(candidates) ) {
+                                       /* only complain for non-range IDLs */
+                                       Debug( LDAP_DEBUG_TRACE,
+                                               LDAP_XSTRING(mdb_search)
+                                               ": candidate %ld not found\n",
+                                               (long) id, 0, 0 );
+                               } else {
+                                       /* get the next ID from the DB */
+                                       rs->sr_err = mdb_get_nextid( mci, &cursor );
+                                       if ( rs->sr_err == MDB_NOTFOUND ) {
+                                               break;
+                                       }
+                                       if ( rs->sr_err ) {
+                                               rs->sr_err = LDAP_OTHER;
+                                               rs->sr_text = "internal error in get_nextid";
+                                               send_ldap_result( op, rs );
+                                               goto done;
+                                       }
+                                       cursor--;
+                               }
+
+                               goto loop_continue;
+                       } else if ( rs->sr_err ) {
+                               rs->sr_err = LDAP_OTHER;
+                               rs->sr_text = "internal error in mdb_id2edata";
+                               send_ldap_result( op, rs );
+                               goto done;
+                       }
+
                        rs->sr_err = mdb_entry_decode( op, &edata, &e );
                        if ( rs->sr_err ) {
                                rs->sr_err = LDAP_OTHER;