]> git.sur5r.net Git - openldap/commitdiff
ITS#7180 fix mdb_entry_get when mdb_entry_next was not called
authorHoward Chu <hyc@openldap.org>
Fri, 24 Feb 2012 23:20:17 +0000 (15:20 -0800)
committerHoward Chu <hyc@openldap.org>
Fri, 24 Feb 2012 23:20:17 +0000 (15:20 -0800)
servers/slapd/back-mdb/tools.c

index 10622e08c9614bca6d5b13d2e196580c45774c95..7dbb136ebc3fad879fe33b676bd56ce8e217a302 100644 (file)
@@ -369,7 +369,24 @@ Entry*
 mdb_tool_entry_get( BackendDB *be, ID id )
 {
        Entry *e = NULL;
+       int rc;
 
+       if ( !txn ) {
+               struct mdb_info *mdb = (struct mdb_info *) be->be_private;
+               rc = mdb_txn_begin( mdb->mi_dbenv, NULL,
+                       (slapMode & SLAP_TOOL_READONLY) ? MDB_RDONLY : 0, &txn );
+               if ( rc )
+                       return NULL;
+       }
+       if ( !cursor ) {
+               struct mdb_info *mdb = (struct mdb_info *) be->be_private;
+               rc = mdb_cursor_open( txn, mdb->mi_id2entry, &cursor );
+               if ( rc ) {
+                       mdb_txn_abort( txn );
+                       txn = NULL;
+                       return NULL;
+               }
+       }
        (void)mdb_tool_entry_get_int( be, id, &e );
        return e;
 }