]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-mdb/tools.c
Add debug msg if adding entry to logDB fails
[openldap] / servers / slapd / back-mdb / tools.c
index c805444063c56a9d95e16cf6576050b403765137..7cbea623954d02b995f74deeccbbc2e204fa926c 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2011-2015 The OpenLDAP Foundation.
+ * Copyright 2011-2017 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -198,6 +198,14 @@ int mdb_tool_entry_close(
                mdb_cursor_close( cursor );
                cursor = NULL;
        }
+       {
+               struct mdb_info *mdb = be->be_private;
+               if ( mdb ) {
+                       int i;
+                       for (i=0; i<mdb->mi_nattrs; i++)
+                               mdb->mi_attrs[i]->ai_cursor = NULL;
+               }
+       }
        if( mdb_tool_txn ) {
                int rc;
                if (( rc = mdb_txn_commit( mdb_tool_txn ))) {
@@ -394,7 +402,7 @@ mdb_tool_entry_get_int( BackendDB *be, ID id, Entry **ep )
                        }
                }
        }
-       rc = mdb_entry_decode( &op, mdb_tool_txn, &data, &e );
+       rc = mdb_entry_decode( &op, mdb_tool_txn, &data, id, &e );
        e->e_id = id;
        if ( !BER_BVISNULL( &dn )) {
                e->e_name = dn;
@@ -445,7 +453,6 @@ static int mdb_tool_next_id(
        struct berval *text,
        int hole )
 {
-       struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private;
        struct berval dn = e->e_name;
        struct berval ndn = e->e_nname;
        struct berval pdn, npdn, nmatched;
@@ -745,6 +752,7 @@ done:
                        mdb_tool_txn = NULL;
                        idcursor = NULL;
                        if( rc != 0 ) {
+                               mdb->mi_numads = 0;
                                snprintf( text->bv_val, text->bv_len,
                                                "txn_commit failed: %s (%d)",
                                                mdb_strerror(rc), rc );
@@ -1015,6 +1023,7 @@ done:
        if( rc == 0 ) {
                rc = mdb_txn_commit( mdb_tool_txn );
                if( rc != 0 ) {
+                       mdb->mi_numads = 0;
                        snprintf( text->bv_val, text->bv_len,
                                        "txn_commit failed: %s (%d)",
                                        mdb_strerror(rc), rc );
@@ -1396,7 +1405,7 @@ int mdb_tool_idl_add(
        dbi = ai->ai_dbi;
        for (i=0; keys[i].bv_val; i++) {
        itmp.kstr = keys[i];
-       ic = tavl_find( (Avlnode *)ai->ai_root, &itmp, mdb_tool_idl_cmp );
+       ic = tavl_find( ai->ai_root, &itmp, mdb_tool_idl_cmp );
 
        /* No entry yet, create one */
        if ( !ic ) {
@@ -1418,7 +1427,7 @@ int mdb_tool_idl_add(
                ic->count = 0;
                ic->offset = 0;
                ic->flags = 0;
-               tavl_insert( (Avlnode **)&ai->ai_root, ic, mdb_tool_idl_cmp,
+               tavl_insert( &ai->ai_root, ic, mdb_tool_idl_cmp,
                        avl_dup_error );
 
                /* load existing key count here */
@@ -1507,7 +1516,6 @@ mdb_dn2id_upgrade( BackendDB *be ) {
        MDB_txn *mt;
        MDB_cursor *mc = NULL;
        MDB_val key, data;
-       char *ptr;
        int rc, writes=0, depth=0;
        int enable_meter = 0;
        ID id = 0, *num, count = 0;