]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/referral.c
Unify use of BDB lockers
[openldap] / servers / slapd / back-bdb / referral.c
index dde3aa43d9a0890f2345306f598081193266c823..d31056eebbc91bd0e28ea1e6ed1983e532ceaad7 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2006 The OpenLDAP Foundation.
+ * Copyright 2000-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -91,17 +91,20 @@ dn2entry_retry:
                                (long) op->o_tag, op->o_req_dn.bv_val, e->e_name.bv_val );
 
                        if( is_entry_referral( e ) ) {
+                               BerVarray ref = get_entry_referrals( op, e );
                                rc = LDAP_OTHER;
-                               rs->sr_ref = get_entry_referrals( op, e );
+                               rs->sr_ref = referral_rewrite( ref, NULL,
+                                       &op->o_req_dn, LDAP_SCOPE_DEFAULT );
+                               ber_bvarray_free( ref );
                                if ( rs->sr_ref ) {
                                        rs->sr_matched = ber_strdup_x(
                                        e->e_name.bv_val, op->o_tmpmemctx );
                                }
                        }
 
-                       bdb_cache_return_entry_r (bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
+                       bdb_cache_return_entry_r (bdb, e, &lock);
                        e = NULL;
-               } else if ( !be_issuffix( op->o_bd, &op->o_req_ndn) && default_referral != NULL ) {
+               } else if ( !be_issuffix( op->o_bd, &op->o_req_ndn ) && default_referral != NULL ) {
                        rc = LDAP_OTHER;
                        rs->sr_ref = referral_rewrite( default_referral,
                                NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
@@ -153,7 +156,7 @@ dn2entry_retry:
                ber_bvarray_free( refs );
        }
 
-       bdb_cache_return_entry_r(bdb->bi_dbenv, &bdb->bi_cache, e, &lock);
+       bdb_cache_return_entry_r(bdb, e, &lock);
        LOCK_ID_FREE ( bdb->bi_dbenv, locker );
        return rc;
 }