Index: servers/slapd/back-bdb/init.c =================================================================== RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/back-bdb/init.c,v retrieving revision 1.298 retrieving revision 1.299 diff -u -r1.298 -r1.299 --- servers/slapd/back-bdb/init.c 2 Nov 2008 22:06:11 -0000 1.298 +++ servers/slapd/back-bdb/init.c 3 Nov 2008 12:00:00 -0000 1.299 @@ -584,6 +584,17 @@ ber_bvarray_free( bdb->bi_db_config ); bdb->bi_db_config = NULL; + if( bdb->bi_dbenv ) { + /* Free cache locker if we enabled locking. + * TXNs must all be closed before DBs... + */ + if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_cache.c_txn ) { + TXN_ABORT( bdb->bi_cache.c_txn ); + bdb->bi_cache.c_txn = NULL; + } + bdb_reader_flush( bdb->bi_dbenv ); + } + while( bdb->bi_databases && bdb->bi_ndatabases-- ) { db = bdb->bi_databases[bdb->bi_ndatabases]; rc = db->bdi_db->close( db->bdi_db, 0 ); @@ -614,13 +625,6 @@ /* close db environment */ if( bdb->bi_dbenv ) { - /* Free cache locker if we enabled locking */ - if ( !( slapMode & SLAP_TOOL_QUICK ) && bdb->bi_cache.c_txn ) { - TXN_ABORT( bdb->bi_cache.c_txn ); - bdb->bi_cache.c_txn = NULL; - } - bdb_reader_flush( bdb->bi_dbenv ); - /* force a checkpoint, but not if we were ReadOnly, * and not in Quick mode since there are no transactions there. */ Index: servers/slapd/backend.c =================================================================== RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/backend.c,v retrieving revision 1.403 retrieving revision 1.404 diff -u -r1.403 -r1.404 --- servers/slapd/backend.c 2 Nov 2008 06:58:50 -0000 1.403 +++ servers/slapd/backend.c 3 Nov 2008 12:23:05 -0000 1.404 @@ -349,11 +349,13 @@ } if ( be->bd_info->bi_db_close ) { - be->bd_info->bi_db_close( be, NULL ); + rc = be->bd_info->bi_db_close( be, NULL ); + if ( rc ) return rc; } if( be->bd_info->bi_close ) { - be->bd_info->bi_close( be->bd_info ); + rc = be->bd_info->bi_close( be->bd_info ); + if ( rc ) return rc; } return 0; Index: servers/slapd/slapacl.c =================================================================== RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/slapacl.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- servers/slapd/slapacl.c 7 Jan 2008 23:20:09 -0000 1.31 +++ servers/slapd/slapacl.c 3 Nov 2008 12:23:05 -0000 1.32 @@ -399,7 +399,8 @@ } } - slap_tool_destroy(); + if ( slap_tool_destroy()) + rc = EXIT_FAILURE; return rc; } Index: servers/slapd/slapadd.c =================================================================== RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/slapadd.c,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- servers/slapd/slapadd.c 22 Mar 2008 15:01:23 -0000 1.54 +++ servers/slapd/slapadd.c 3 Nov 2008 12:23:05 -0000 1.55 @@ -447,7 +447,8 @@ } } - slap_tool_destroy(); + if ( slap_tool_destroy()) + rc = EXIT_FAILURE; return rc; } Index: servers/slapd/slapauth.c =================================================================== RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/slapauth.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- servers/slapd/slapauth.c 7 Jan 2008 23:20:09 -0000 1.13 +++ servers/slapd/slapauth.c 3 Nov 2008 12:23:05 -0000 1.14 @@ -166,7 +166,8 @@ if ( !BER_BVISNULL( &authzID ) ) { op->o_tmpfree( authzID.bv_val, op->o_tmpmemctx ); } - slap_tool_destroy(); + if ( slap_tool_destroy()) + rc = EXIT_FAILURE; return rc; } Index: servers/slapd/slapcat.c =================================================================== RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/slapcat.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- servers/slapd/slapcat.c 11 Apr 2008 10:20:01 -0000 1.12 +++ servers/slapd/slapcat.c 3 Nov 2008 12:23:05 -0000 1.13 @@ -134,6 +134,7 @@ be->be_entry_close( be ); - slap_tool_destroy(); + if ( slap_tool_destroy()) + rc = EXIT_FAILURE; return rc; } Index: servers/slapd/slapcommon.c =================================================================== RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/slapcommon.c,v retrieving revision 1.88 retrieving revision 1.89 diff -u -r1.88 -r1.89 --- servers/slapd/slapcommon.c 7 Jan 2008 23:20:09 -0000 1.88 +++ servers/slapd/slapcommon.c 3 Nov 2008 12:23:05 -0000 1.89 @@ -740,13 +740,16 @@ } } -void slap_tool_destroy( void ) +int slap_tool_destroy( void ) { + int rc = 0; if ( !dryrun ) { if ( need_shutdown ) { - slap_shutdown( be ); + if ( slap_shutdown( be )) + rc = EXIT_FAILURE; } - slap_destroy(); + if ( slap_destroy()) + rc = EXIT_FAILURE; } #ifdef SLAPD_MODULES if ( slapMode == SLAP_SERVER_MODE ) { @@ -772,4 +775,5 @@ if ( ldiffp && ldiffp != &dummy ) { ldif_close( ldiffp ); } + return rc; } Index: servers/slapd/slapcommon.h =================================================================== RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/slapcommon.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- servers/slapd/slapcommon.h 7 Jan 2008 23:20:09 -0000 1.19 +++ servers/slapd/slapcommon.h 3 Nov 2008 12:23:05 -0000 1.20 @@ -101,6 +101,6 @@ int tool, int argc, char **argv )); -void slap_tool_destroy LDAP_P((void)); +int slap_tool_destroy LDAP_P((void)); #endif /* SLAPCOMMON_H_ */ Index: servers/slapd/slapdn.c =================================================================== RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/slapdn.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- servers/slapd/slapdn.c 7 Jan 2008 23:20:09 -0000 1.10 +++ servers/slapd/slapdn.c 3 Nov 2008 12:23:05 -0000 1.11 @@ -99,7 +99,8 @@ } } - slap_tool_destroy(); + if ( slap_tool_destroy()) + rc = EXIT_FAILURE; return rc; } Index: servers/slapd/slapindex.c =================================================================== RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/slapindex.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- servers/slapd/slapindex.c 7 Jan 2008 23:20:09 -0000 1.7 +++ servers/slapd/slapindex.c 3 Nov 2008 12:23:05 -0000 1.8 @@ -99,6 +99,7 @@ (void) be->be_entry_close( be ); - slap_tool_destroy(); + if ( slap_tool_destroy()) + rc = EXIT_FAILURE; return( rc ); } Index: servers/slapd/slaptest.c =================================================================== RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/slaptest.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- servers/slapd/slaptest.c 7 Jan 2008 23:20:09 -0000 1.11 +++ servers/slapd/slaptest.c 3 Nov 2008 12:23:05 -0000 1.12 @@ -108,7 +108,8 @@ fprintf( stderr, "config file testing succeeded\n"); } - slap_tool_destroy(); + if ( slap_tool_destroy()) + rc = EXIT_FAILURE; return rc; }