]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/id2entry.c
Unify use of BDB lockers
[openldap] / servers / slapd / back-bdb / id2entry.c
index 3c5580ea9cb62ba08262c04d4ae014490962fe37..8ef594023c4ccb550e4f6f5285a2411d1cad7252 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
@@ -130,6 +130,7 @@ int bdb_id2entry(
        rc = cursor->c_get( cursor, &key, &data, DB_SET );
        if ( rc ) goto leave;
 
+
        eh.bv.bv_val = buf;
        eh.bv.bv_len = data.size;
        rc = entry_header( &eh );
@@ -139,7 +140,7 @@ int bdb_id2entry(
        data.flags ^= DB_DBT_PARTIAL;
        data.ulen = 0;
        rc = cursor->c_get( cursor, &key, &data, DB_CURRENT );
-       if ( rc != ENOMEM ) goto leave;
+       if ( rc != DB_BUFFER_SMALL ) goto leave;
 
        /* Allocate a block and retrieve the data */
        off = eh.data - eh.bv.bv_val;
@@ -259,14 +260,13 @@ int bdb_entry_release(
 
                /* lock is freed with txn */
                if ( !boi || boi->boi_txn ) {
-                       bdb_unlocked_cache_return_entry_rw( &bdb->bi_cache, e, rw );
+                       bdb_unlocked_cache_return_entry_rw( bdb, e, rw );
                } else {
                        struct bdb_lock_info *bli, *prev;
                        for ( prev=(struct bdb_lock_info *)&boi->boi_locks,
                                bli = boi->boi_locks; bli; prev=bli, bli=bli->bli_next ) {
                                if ( bli->bli_id == e->e_id ) {
-                                       bdb_cache_return_entry_rw( bdb->bi_dbenv, &bdb->bi_cache,
-                                               e, rw, &bli->bli_lock );
+                                       bdb_cache_return_entry_rw( bdb, e, rw, &bli->bli_lock );
                                        prev->bli_next = bli->bli_next;
                                        op->o_tmpfree( bli, op->o_tmpmemctx );
                                        break;
@@ -410,7 +410,7 @@ dn2entry_retry:
 return_results:
        if( rc != LDAP_SUCCESS ) {
                /* free entry */
-               bdb_cache_return_entry_rw(bdb->bi_dbenv, &bdb->bi_cache, e, rw, &lock);
+               bdb_cache_return_entry_rw(bdb, e, rw, &lock);
 
        } else {
                if ( slapMode == SLAP_SERVER_MODE ) {
@@ -437,7 +437,7 @@ return_results:
                        }
                } else {
                        *ent = entry_dup( e );
-                       bdb_cache_return_entry_rw(bdb->bi_dbenv, &bdb->bi_cache, e, rw, &lock);
+                       bdb_cache_return_entry_rw(bdb, e, rw, &lock);
                }
        }