|
|
f92ce9 |
From bf2263bac10b890cdfc1fb7cd37f868785190cce Mon Sep 17 00:00:00 2001
|
|
|
f92ce9 |
From: Noriko Hosoi <nhosoi@redhat.com>
|
|
|
f92ce9 |
Date: Wed, 10 Dec 2014 17:12:00 -0800
|
|
|
f92ce9 |
Subject: [PATCH 44/53] Ticket #47960 - cookie_change_info returns random
|
|
|
f92ce9 |
negative number if there was no change in a tree
|
|
|
f92ce9 |
|
|
|
f92ce9 |
Description: When no changes had not been made, Retro Changelog db
|
|
|
f92ce9 |
was empty and the search callback sync_handle_cnum_entry in the
|
|
|
f92ce9 |
Content Synchronization had no chance to be called. If it was not
|
|
|
f92ce9 |
called, an uninitialized garbage value in Sync_CallBackData was set
|
|
|
f92ce9 |
to cookie_change_info.
|
|
|
f92ce9 |
|
|
|
f92ce9 |
This patch checks if the search callback sync_handle_cnum_entry is
|
|
|
f92ce9 |
called or not. If it is not called, set 0 to cookie_change_info.
|
|
|
f92ce9 |
|
|
|
f92ce9 |
https://fedorahosted.org/389/ticket/47960
|
|
|
f92ce9 |
|
|
|
f92ce9 |
Reviewed by rmeggins@redhat.com and tbordaz@redhat.com (Thank you,
|
|
|
f92ce9 |
Rich and Thierry!!)
|
|
|
f92ce9 |
|
|
|
f92ce9 |
(cherry picked from commit a908c6b57cd77ff2f6e2fe0fe1fa2e0eccba77e0)
|
|
|
f92ce9 |
(cherry picked from commit b7a472c71db4671c127584fcf7bfd8c75930bc8c)
|
|
|
f92ce9 |
---
|
|
|
f92ce9 |
ldap/servers/plugins/sync/sync.h | 2 ++
|
|
|
f92ce9 |
ldap/servers/plugins/sync/sync_util.c | 14 ++++++++++----
|
|
|
f92ce9 |
2 files changed, 12 insertions(+), 4 deletions(-)
|
|
|
f92ce9 |
|
|
|
f92ce9 |
diff --git a/ldap/servers/plugins/sync/sync.h b/ldap/servers/plugins/sync/sync.h
|
|
|
f92ce9 |
index 9c2d8be..0bcec7a 100644
|
|
|
f92ce9 |
--- a/ldap/servers/plugins/sync/sync.h
|
|
|
f92ce9 |
+++ b/ldap/servers/plugins/sync/sync.h
|
|
|
f92ce9 |
@@ -76,6 +76,8 @@ typedef struct sync_update {
|
|
|
f92ce9 |
Slapi_Entry *upd_e;
|
|
|
f92ce9 |
} Sync_UpdateNode;
|
|
|
f92ce9 |
|
|
|
f92ce9 |
+#define SYNC_CALLBACK_PREINIT (-1)
|
|
|
f92ce9 |
+
|
|
|
f92ce9 |
typedef struct sync_callback {
|
|
|
f92ce9 |
Slapi_PBlock *orig_pb;
|
|
|
f92ce9 |
int changenr;
|
|
|
f92ce9 |
diff --git a/ldap/servers/plugins/sync/sync_util.c b/ldap/servers/plugins/sync/sync_util.c
|
|
|
f92ce9 |
index de65b99..af22bcb 100644
|
|
|
f92ce9 |
--- a/ldap/servers/plugins/sync/sync_util.c
|
|
|
f92ce9 |
+++ b/ldap/servers/plugins/sync/sync_util.c
|
|
|
f92ce9 |
@@ -373,6 +373,7 @@ sync_handle_cnum_entry(Slapi_Entry *e, void *cb_data)
|
|
|
f92ce9 |
if( NULL != value && NULL != value->bv_val &&
|
|
|
f92ce9 |
'\0' != value->bv_val[0]) {
|
|
|
f92ce9 |
cb->changenr = sync_number2int(value->bv_val);
|
|
|
f92ce9 |
+ cb->cb_err = 0; /* changenr successfully set */
|
|
|
f92ce9 |
}
|
|
|
f92ce9 |
}
|
|
|
f92ce9 |
}
|
|
|
f92ce9 |
@@ -500,7 +501,7 @@ sync_cookie_get_change_info(Sync_CallBackData *scbd)
|
|
|
f92ce9 |
slapi_pblock_init(seq_pb);
|
|
|
f92ce9 |
|
|
|
f92ce9 |
slapi_seq_internal_set_pb(seq_pb, base, SLAPI_SEQ_LAST, attrname, NULL, NULL, 0, 0,
|
|
|
f92ce9 |
- plugin_get_default_component_id(), 0);
|
|
|
f92ce9 |
+ plugin_get_default_component_id(), 0);
|
|
|
f92ce9 |
|
|
|
f92ce9 |
rc = slapi_seq_internal_callback_pb (seq_pb, scbd, NULL, sync_handle_cnum_entry, NULL);
|
|
|
f92ce9 |
slapi_pblock_destroy(seq_pb);
|
|
|
f92ce9 |
@@ -518,15 +519,20 @@ sync_cookie_create (Slapi_PBlock *pb)
|
|
|
f92ce9 |
|
|
|
f92ce9 |
Sync_CallBackData scbd;
|
|
|
f92ce9 |
int rc;
|
|
|
f92ce9 |
- Sync_Cookie *sc = (Sync_Cookie *)slapi_ch_malloc(sizeof(Sync_Cookie));
|
|
|
f92ce9 |
-
|
|
|
f92ce9 |
+ Sync_Cookie *sc = (Sync_Cookie *)slapi_ch_calloc(1, sizeof(Sync_Cookie));
|
|
|
f92ce9 |
|
|
|
f92ce9 |
+ scbd.cb_err = SYNC_CALLBACK_PREINIT;
|
|
|
f92ce9 |
rc = sync_cookie_get_change_info (&scbd);
|
|
|
f92ce9 |
|
|
|
f92ce9 |
if (rc == 0) {
|
|
|
f92ce9 |
sc->cookie_server_signature = sync_cookie_get_server_info(pb);
|
|
|
f92ce9 |
sc->cookie_client_signature = sync_cookie_get_client_info(pb);
|
|
|
f92ce9 |
- sc->cookie_change_info = scbd.changenr;
|
|
|
f92ce9 |
+ if (scbd.cb_err == SYNC_CALLBACK_PREINIT) {
|
|
|
f92ce9 |
+ /* changenr is not initialized. */
|
|
|
f92ce9 |
+ sc->cookie_change_info = 0;
|
|
|
f92ce9 |
+ } else {
|
|
|
f92ce9 |
+ sc->cookie_change_info = scbd.changenr;
|
|
|
f92ce9 |
+ }
|
|
|
f92ce9 |
} else {
|
|
|
f92ce9 |
slapi_ch_free ((void **)&sc);
|
|
|
f92ce9 |
sc = NULL;
|
|
|
f92ce9 |
--
|
|
|
f92ce9 |
1.9.3
|
|
|
f92ce9 |
|