]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-mdb/search.c
Happy new year (belated)
[openldap] / servers / slapd / back-mdb / search.c
index 30e2eeda655b66a2ecdcfc1f9cbf17abcf3de18f..4cac2b30df00597abc44d48429c2593120cd9172 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2013 The OpenLDAP Foundation.
+ * Copyright 2000-2014 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -538,6 +538,7 @@ dn2entry_retry:
        /* select candidates */
        if ( op->oq_search.rs_scope == LDAP_SCOPE_BASE ) {
                rs->sr_err = base_candidate( op->o_bd, base, candidates );
+               scopes[0].mid = 0;
                ncand = 1;
        } else {
                if ( op->ors_scope == LDAP_SCOPE_ONELEVEL ) {
@@ -649,8 +650,10 @@ dn2entry_retry:
                                        continue;
                                iscopes[cursor++] = scopes[cscope].mid;
                        }
+                       iscopes[0] = scopes[0].mid - 1;
+               } else {
+                       iscopes[0] = 0;
                }
-               iscopes[0] = scopes[0].mid - 1;
 
                isc.id = base->e_id;
                isc.numrdns = 0;
@@ -856,7 +859,7 @@ notfound:
                        int i;
 
                        /* child of base, just append RDNs to base->e_name */
-                       if ( nsubs < ncand || isc.nscope == 1 ) {
+                       if ( nsubs < ncand || isc.scopes[isc.nscope].mid == base->e_id ) {
                                pdn = base->e_name;
                                pndn = base->e_nname;
                        } else {
@@ -974,6 +977,9 @@ notfound:
                                        break;
                                default:                /* entry not sent */
                                        break;
+                               case LDAP_BUSY:
+                                       send_ldap_result( op, rs );
+                                       goto done;
                                case LDAP_UNAVAILABLE:
                                case LDAP_SIZELIMIT_EXCEEDED:
                                        if ( rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ) {
@@ -1055,6 +1061,8 @@ done:
        if ( moi == &opinfo ) {
                mdb_txn_reset( moi->moi_txn );
                LDAP_SLIST_REMOVE( &op->o_extra, &moi->moi_oe, OpExtra, oe_next );
+       } else {
+               moi->moi_ref--;
        }
        if( rs->sr_v2ref ) {
                ber_bvarray_free( rs->sr_v2ref );