From 6604d0e6c1adbc63444bcdcdec9bef1a337e677b Mon Sep 17 00:00:00 2001
From: Quanah Gibson-Mount <quanah@openldap.org>
Date: Tue, 17 Feb 2009 22:17:20 +0000
Subject: [PATCH] ITS#5954

---
 CHANGES                  |  1 +
 servers/slapd/syncrepl.c | 13 +++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/CHANGES b/CHANGES
index bac96ae2f7..ed22a52b2a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,7 @@ OpenLDAP 2.4 Change Log
 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 slapo-rwm objectClass preservation (ITS#5760)
 
 OpenLDAP 2.4.14 Release (2009/02/14)
diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c
index d99af0ef2e..b6686958f3 100644
--- a/servers/slapd/syncrepl.c
+++ b/servers/slapd/syncrepl.c
@@ -4325,13 +4325,22 @@ add_syncrepl(
 			BER_BVISNULL( &si->si_bindconf.sb_uri ) ?
 			"(null)" : si->si_bindconf.sb_uri.bv_val, 0, 0 );
 		if ( c->be->be_syncinfo ) {
+			syncinfo_t *sip;
+
 			si->si_cookieState = c->be->be_syncinfo->si_cookieState;
+
+			// add new syncrepl to end of list (same order as when deleting)
+			for ( sip = c->be->be_syncinfo; sip->si_next; sip = sip->si_next );
+			sip->si_next = si;
 		} else {
 			si->si_cookieState = ch_calloc( 1, sizeof( cookie_state ));
 			ldap_pvt_thread_mutex_init( &si->si_cookieState->cs_mutex );
+
+			c->be->be_syncinfo = si;
 		}
-		si->si_next = c->be->be_syncinfo;
-		c->be->be_syncinfo = si;
+
+		si->si_next = NULL;
+
 		return 0;
 	}
 }
-- 
GitLab