]> git.sur5r.net Git - openldap/commitdiff
attrdb fixes
authorHoward Chu <hyc@openldap.org>
Wed, 3 Apr 2013 22:04:01 +0000 (15:04 -0700)
committerHoward Chu <hyc@openldap.org>
Fri, 5 Apr 2013 10:03:07 +0000 (03:03 -0700)
servers/slapd/back-mdb/attr.c
servers/slapd/bconfig.c

index 52d3062a6805a761c11c7a2061f3bab43f84753a..26f84b2850b609767a20c5120f3e44a17e249483 100644 (file)
@@ -94,6 +94,7 @@ mdb_attr_dbs_open(
 {
        struct mdb_info *mdb = (struct mdb_info *) be->be_private;
        MDB_txn *txn;
+       MDB_dbi *dbis = NULL;
        int i, flags;
        int rc;
 
@@ -109,6 +110,7 @@ mdb_attr_dbs_open(
                                cr->msg, 0, 0 );
                        return rc;
                }
+               dbis = ch_calloc( 1, mdb->mi_nattrs * sizeof(MDB_dbi) );
        } else {
                rc = 0;
        }
@@ -133,6 +135,9 @@ mdb_attr_dbs_open(
                                cr->msg, 0, 0 );
                        break;
                }
+               /* Remember newly opened DBI handles */
+               if ( dbis )
+                       dbis[i] = mdb->mi_attrs[i]->ai_dbi;
        }
 
        /* Only commit if this is our txn */
@@ -150,6 +155,17 @@ mdb_attr_dbs_open(
                } else {
                        mdb_txn_abort( txn );
                }
+               /* Something failed, forget anything we just opened */
+               if ( rc ) {
+                       for ( i=0; i<mdb->mi_nattrs; i++ ) {
+                               if ( dbis[i] ) {
+                                       mdb->mi_attrs[i]->ai_dbi = 0;
+                                       mdb->mi_attrs[i]->ai_indexmask |= MDB_INDEX_DELETING;
+                               }
+                       }
+                       mdb_attr_flush( mdb );
+               }
+               ch_free( dbis );
        }
 
        return rc;
index 4fb764b3e025023c9ca33eab2e1359f2c9adc7d6..38d4bbea42a40c0589670992a7d9184738006740 100644 (file)
@@ -5949,8 +5949,11 @@ out:
                ca->reply = msg;
        }
 
-       if ( ca->cleanup )
-               ca->cleanup( ca );
+       if ( ca->cleanup ) {
+               i = ca->cleanup( ca );
+               if (rc == LDAP_SUCCESS)
+                       rc = i;
+       }
 out_noop:
        if ( rc == LDAP_SUCCESS ) {
                attrs_free( save_attrs );