amoralej / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 years ago
Clone
Blob Blame History Raw
From 9c929dbfcd1687ba43b2b2ee649c0e6522365fad Mon Sep 17 00:00:00 2001
From: Ludwig Krispenz <lkrispen@redhat.com>
Date: Wed, 4 Apr 2018 08:59:15 +0200
Subject: [PATCH] Ticket 49631 - same csn generated twice

Bug: if in the csn adjustment the local time was less or equal than the remote time
     the sequence number has always been adjusted to remote++
     but if the csn time was equal and the local seq number was larger the effect
     was a reset of the csn generato.

Fix: correctly handles seqnum in csn adjustment

Reviewed by: Mark, thanks
---
 ldap/servers/slapd/csngen.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ldap/servers/slapd/csngen.c b/ldap/servers/slapd/csngen.c
index 4ac45acf0..3afc9176b 100644
--- a/ldap/servers/slapd/csngen.c
+++ b/ldap/servers/slapd/csngen.c
@@ -338,7 +338,11 @@ csngen_adjust_time(CSNGen *gen, const CSN *csn)
                we have increased the time, we can decrease the seqnum
                and still guarantee that any new CSNs generated will be
                > any current CSNs we have generated */
-            gen->state.seq_num = remote_seqnum + 1;
+            if (remote_seqnum < gen->state.seq_num) {
+                gen->state.seq_num ++;
+            } else {
+                gen->state.seq_num = remote_seqnum + 1;
+            }
         }
         if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) {
             slapi_log_err(SLAPI_LOG_REPL, "csngen_adjust_time",
-- 
2.13.6