From 40e796c5472f689fb0fb305afc511bf3d095c58b Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sat, 8 Sep 2007 05:26:03 +0000 Subject: [PATCH] ITS#5129 fix alock_close with Quick mode --- servers/slapd/alock.c | 6 ++++-- servers/slapd/alock.h | 2 +- servers/slapd/back-bdb/init.c | 8 +++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/servers/slapd/alock.c b/servers/slapd/alock.c index c7bb16d56f..d469d3b56f 100644 --- a/servers/slapd/alock.c +++ b/servers/slapd/alock.c @@ -516,7 +516,7 @@ alock_scan ( alock_info_t * info ) } int -alock_close ( alock_info_t * info ) +alock_close ( alock_info_t * info, int nosave ) { alock_slot_t slot_data; int res; @@ -540,7 +540,9 @@ alock_close ( alock_info_t * info ) free (slot_data.al_appname); return ALOCK_UNSTABLE; } - slot_data.al_lock = ALOCK_UNLOCKED | (slot_data.al_lock & ALOCK_NOSAVE); + slot_data.al_lock = ALOCK_UNLOCKED; + if ( nosave ) + slot_data.al_lock |= ALOCK_NOSAVE; res = alock_write_slot (info, &slot_data); if (res == -1) { close (info->al_fd); diff --git a/servers/slapd/alock.h b/servers/slapd/alock.h index 0f78fffdd0..947bc2b308 100644 --- a/servers/slapd/alock.h +++ b/servers/slapd/alock.h @@ -66,7 +66,7 @@ typedef struct alock_slot { LDAP_SLAPD_F (int) alock_open LDAP_P(( alock_info_t * info, const char * appname, const char * envdir, int locktype )); LDAP_SLAPD_F (int) alock_scan LDAP_P(( alock_info_t * info )); -LDAP_SLAPD_F (int) alock_close LDAP_P(( alock_info_t * info )); +LDAP_SLAPD_F (int) alock_close LDAP_P(( alock_info_t * info, int nosave )); LDAP_SLAPD_F (int) alock_recover LDAP_P(( alock_info_t * info )); LDAP_END_DECL diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 88dee474bd..ff7957f237 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -195,9 +195,11 @@ bdb_db_open( BackendDB *be, ConfigReply *cr ) be->be_suffix[0].bv_val, 0, 0 ); if ( quick ) { Debug( LDAP_DEBUG_ANY, - "Cannot use Quick mode, perform manual recovery first.\n", + "Cannot use Quick mode; perform manual recovery first.\n", 0, 0, 0 ); - return -1; + slapMode ^= SLAP_TOOL_QUICK; + rc = -1; + goto fail; } else { Debug( LDAP_DEBUG_ANY, "Performing database recovery to activate new settings.\n", @@ -614,7 +616,7 @@ bdb_db_close( BackendDB *be, ConfigReply *cr ) } } - rc = alock_close( &bdb->bi_alock_info ); + rc = alock_close( &bdb->bi_alock_info, slapMode & SLAP_TOOL_QUICK ); if( rc != 0 ) { Debug( LDAP_DEBUG_ANY, "bdb_db_close: database \"%s\": alock_close failed\n", -- 2.39.5