/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2011-2012 The OpenLDAP Foundation.
+ * Copyright 2011-2013 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
ldap_pvt_thread_cond_init( &mdb_tool_index_cond_work );
if ( mdb->mi_nattrs ) {
int i;
+#if 0 /* threaded indexing has no performance advantage */
mdb_tool_threads = slap_tool_thread_max - 1;
+#endif
if ( mdb_tool_threads > 1 ) {
mdb_tool_index_rec = ch_calloc( mdb->mi_nattrs, sizeof( IndexRec ));
mdb_tool_index_tcount = mdb_tool_threads - 1;
previd = *(ID *)key.mv_data;
id = previd;
+ if ( !data.mv_size )
+ goto next;
+
if ( tool_filter || tool_base ) {
static Operation op = {0};
static Opheader ohdr = {0};
goto done;
}
}
+ if ( !data.mv_size ) {
+ rc = LDAP_NO_SUCH_OBJECT;
+ goto done;
+ }
op.o_hdr = &ohdr;
op.o_bd = be;
ch_free( dn.bv_val );
ch_free( ndn.bv_val );
rc = LDAP_NO_SUCH_OBJECT;
+ goto done;
}
}
}
if( rc == 0 ) {
mdb_writes++;
if ( mdb_writes >= mdb_writes_per_commit ) {
+ MDB_val key;
unsigned i;
MDB_TOOL_IDL_FLUSH( be, txi );
rc = mdb_txn_commit( txi );
mdb_strerror(rc), rc, 0 );
e->e_id = NOID;
}
+ mdb_cursor_close( cursor );
txi = NULL;
+ /* Must close the read txn to allow old pages to be reclaimed. */
+ mdb_txn_abort( txn );
+ /* and then reopen it so that tool_entry_next still works. */
+ mdb_txn_begin( mi->mi_dbenv, NULL, MDB_RDONLY, &txn );
+ mdb_cursor_open( txn, mi->mi_id2entry, &cursor );
+ key.mv_data = &id;
+ key.mv_size = sizeof(ID);
+ mdb_cursor_get( cursor, &key, NULL, MDB_SET );
}
} else {
unsigned i;
mdb_writes = 0;
+ mdb_cursor_close( cursor );
+ cursor = NULL;
mdb_txn_abort( txi );
for ( i=0; i<mi->mi_nattrs; i++ )
mi->mi_attrs[i]->ai_cursor = NULL;