/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2000-2010 The OpenLDAP Foundation.
+ * Copyright 2000-2016 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
rc = entry_header( &eh );
if ( rc ) goto finish;
- /* Get the size */
- data.flags ^= DB_DBT_PARTIAL;
- data.ulen = 0;
- rc = cursor->c_get( cursor, &key, &data, DB_CURRENT );
- if ( rc != DB_BUFFER_SMALL ) goto finish;
-
- /* Allocate a block and retrieve the data */
- off = eh.data - eh.bv.bv_val;
- eh.bv.bv_len = eh.nvals * sizeof( struct berval ) + data.size;
- eh.bv.bv_val = ch_malloc( eh.bv.bv_len );
- eh.data = eh.bv.bv_val + eh.nvals * sizeof( struct berval );
- data.data = eh.data;
- data.ulen = data.size;
-
- /* skip past already parsed nattr/nvals */
- eh.data += off;
-
- rc = cursor->c_get( cursor, &key, &data, DB_CURRENT );
+ if ( eh.nvals ) {
+ /* Get the size */
+ data.flags ^= DB_DBT_PARTIAL;
+ data.ulen = 0;
+ rc = cursor->c_get( cursor, &key, &data, DB_CURRENT );
+ if ( rc != DB_BUFFER_SMALL ) goto finish;
+
+ /* Allocate a block and retrieve the data */
+ off = eh.data - eh.bv.bv_val;
+ eh.bv.bv_len = eh.nvals * sizeof( struct berval ) + data.size;
+ eh.bv.bv_val = ch_malloc( eh.bv.bv_len );
+ eh.data = eh.bv.bv_val + eh.nvals * sizeof( struct berval );
+ data.data = eh.data;
+ data.ulen = data.size;
+
+ /* skip past already parsed nattr/nvals */
+ eh.data += off;
+
+ rc = cursor->c_get( cursor, &key, &data, DB_CURRENT );
+ }
finish:
cursor->c_close( cursor );
return rc;
}
+ if ( eh.nvals ) {
#ifdef SLAP_ZONE_ALLOC
- rc = entry_decode(&eh, e, bdb->bi_cache.c_zctx);
+ rc = entry_decode(&eh, e, bdb->bi_cache.c_zctx);
#else
- rc = entry_decode(&eh, e);
+ rc = entry_decode(&eh, e);
#endif
+ } else {
+ *e = entry_alloc();
+ }
if( rc == 0 ) {
(*e)->e_id = id;
/* slapMode : SLAP_SERVER_MODE, SLAP_TOOL_MODE,
SLAP_TRUNCATE_MODE, SLAP_UNDEFINED_MODE */
- if ( slapMode == SLAP_SERVER_MODE ) {
+ if ( slapMode & SLAP_SERVER_MODE ) {
/* If not in our cache, just free it */
if ( !e->e_private ) {
#ifdef SLAP_ZONE_ALLOC
bdb_cache_return_entry_rw(bdb, e, rw, &lock);
} else {
- if ( slapMode == SLAP_SERVER_MODE ) {
+ if ( slapMode & SLAP_SERVER_MODE ) {
*ent = e;
/* big drag. we need a place to store a read lock so we can
* release it later?? If we're in a txn, nothing is needed