From 4bee4dd5d7511d57783f0b074cac8e8f7194bc71 Mon Sep 17 00:00:00 2001
From: Quanah Gibson-Mount <quanah@openldap.org>
Date: Wed, 18 Feb 2009 23:16:29 +0000
Subject: [PATCH] ITS#5956

---
 CHANGES                       | 1 +
 servers/slapd/back-bdb/init.c | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/CHANGES b/CHANGES
index a24e680375..6dc78b000e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,7 @@ OpenLDAP 2.4.15 Engineering
 	Fixed libldap GnuTLS compilation (ITS#5955)
 	Fixed slapd corrupt contextCSN (ITS#5947)
 	Fixed slapd syncrepl order to match on add/delete (ITS#5954)
+	Fixed slapd-bdb/hdb behavior with unallocatable shm (ITS#5956)
 	Fixed slapo-rwm objectClass preservation (ITS#5760)
 	Build Environment
 		Fixed tester library linking for windows (ITS#5740)
diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c
index ab1fa16a44..a029fee3c8 100644
--- a/servers/slapd/back-bdb/init.c
+++ b/servers/slapd/back-bdb/init.c
@@ -111,6 +111,7 @@ bdb_db_open( BackendDB *be, ConfigReply *cr )
 	Entry *e = NULL;
 	int do_recover = 0, do_alock_recover = 0;
 	int alockt, quick = 0;
+	int do_retry = 1;
 
 	if ( be->be_suffix == NULL ) {
 		Debug( LDAP_DEBUG_ANY,
@@ -335,11 +336,12 @@ shm_retry:
 		if ( !do_recover && bdb->bi_shm_key ) {
 			bdb->bi_dbenv->close( bdb->bi_dbenv, 0 );
 			rc = db_env_create( &bdb->bi_dbenv, 0 );
-			if( rc == 0 ) {
+			if( rc == 0 && do_retry ) {
 				Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_db_open)
 					": database \"%s\": "
 					"shared memory env open failed, assuming stale env.\n",
 					be->be_suffix[0].bv_val, 0, 0 );
+				do_retry = 0;
 				goto shm_retry;
 			}
 		}
-- 
GitLab