Branch '389-ds-base-1.3.1' - ldap/servers
by Richard Allen Megginson
ldap/servers/plugins/replication/repl_extop.c | 11 ++---------
ldap/servers/slapd/csngen.c | 8 ++++++--
2 files changed, 8 insertions(+), 11 deletions(-)
New commits:
commit 51c1b2a0e4245b90f418f9f909c1d17c564f77f3
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu Jan 16 12:57:22 2014 -0700
Ticket #47516 replication stops with excessive clock skew
https://fedorahosted.org/389/ticket/47516
Reviewed by: nhosoi (Thanks!)
Branch: 389-ds-base-1.3.1
Fix Description: The previous fix was not adequate. Instead, the determination
of whether or not to ignore time skew should be determined in
csngen_adjust_time().
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: yes - document new config param
(cherry picked from commit 9f2b104b0938b21d7c9fe37c736d0e6328843aeb)
(cherry picked from commit a6ec074c6295a59938f313b4fe09430e8f601fab)
diff --git a/ldap/servers/plugins/replication/repl_extop.c b/ldap/servers/plugins/replication/repl_extop.c
index 57249a6..35014a9 100644
--- a/ldap/servers/plugins/replication/repl_extop.c
+++ b/ldap/servers/plugins/replication/repl_extop.c
@@ -835,19 +835,12 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
rc = replica_update_csngen_state_ext (replica, supplier_ruv, replicacsn); /* too much skew */
if (rc == CSN_LIMIT_EXCEEDED)
{
- extern int config_get_ignore_time_skew();
-
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"conn=%" NSPRIu64 " op=%d repl=\"%s\": "
"Excessive clock skew from supplier RUV\n",
(long long unsigned int)connid, opid, repl_root);
- if (!config_get_ignore_time_skew()) {
- response = NSDS50_REPL_EXCESSIVE_CLOCK_SKEW;
- goto send_response;
- } else {
- /* else just continue */
- rc = 0;
- }
+ response = NSDS50_REPL_EXCESSIVE_CLOCK_SKEW;
+ goto send_response;
}
else if (rc != 0)
{
diff --git a/ldap/servers/slapd/csngen.c b/ldap/servers/slapd/csngen.c
index 464a59e..f87f2d1 100644
--- a/ldap/servers/slapd/csngen.c
+++ b/ldap/servers/slapd/csngen.c
@@ -326,6 +326,8 @@ int csngen_adjust_time(CSNGen *gen, const CSN* csn)
time_t remote_time, remote_offset, cur_time;
PRUint16 remote_seqnum;
int rc;
+ extern int config_get_ignore_time_skew();
+ int ignore_time_skew = config_get_ignore_time_skew();
if (gen == NULL || csn == NULL)
return CSN_INVALID_PARAMETER;
@@ -380,7 +382,7 @@ int csngen_adjust_time(CSNGen *gen, const CSN* csn)
remote_offset = remote_time - cur_time;
if (remote_offset > gen->state.remote_offset)
{
- if (remote_offset <= CSN_MAX_TIME_ADJUST)
+ if (ignore_time_skew || (remote_offset <= CSN_MAX_TIME_ADJUST))
{
gen->state.remote_offset = remote_offset;
}
@@ -651,6 +653,8 @@ _csngen_cmp_callbacks (const void *el1, const void *el2)
static int
_csngen_adjust_local_time (CSNGen *gen, time_t cur_time)
{
+ extern int config_get_ignore_time_skew();
+ int ignore_time_skew = config_get_ignore_time_skew();
time_t time_diff = cur_time - gen->state.sampled_time;
if (time_diff == 0) {
@@ -714,7 +718,7 @@ _csngen_adjust_local_time (CSNGen *gen, time_t cur_time)
gen->state.remote_offset);
}
- if (abs (time_diff) > CSN_MAX_TIME_ADJUST)
+ if (!ignore_time_skew && (abs (time_diff) > CSN_MAX_TIME_ADJUST))
{
slapi_log_error (SLAPI_LOG_FATAL, NULL, "_csngen_adjust_local_time: "
"adjustment limit exceeded; value - %d, limit - %d\n",
10 years, 2 months
Branch '389-ds-base-1.3.2' - ldap/servers
by Richard Allen Megginson
ldap/servers/plugins/replication/repl_extop.c | 11 ++---------
ldap/servers/slapd/csngen.c | 8 ++++++--
2 files changed, 8 insertions(+), 11 deletions(-)
New commits:
commit a6ec074c6295a59938f313b4fe09430e8f601fab
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu Jan 16 12:57:22 2014 -0700
Ticket #47516 replication stops with excessive clock skew
https://fedorahosted.org/389/ticket/47516
Reviewed by: nhosoi (Thanks!)
Branch: 389-ds-base-1.3.2
Fix Description: The previous fix was not adequate. Instead, the determination
of whether or not to ignore time skew should be determined in
csngen_adjust_time().
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: yes - document new config param
(cherry picked from commit 9f2b104b0938b21d7c9fe37c736d0e6328843aeb)
diff --git a/ldap/servers/plugins/replication/repl_extop.c b/ldap/servers/plugins/replication/repl_extop.c
index 57249a6..35014a9 100644
--- a/ldap/servers/plugins/replication/repl_extop.c
+++ b/ldap/servers/plugins/replication/repl_extop.c
@@ -835,19 +835,12 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
rc = replica_update_csngen_state_ext (replica, supplier_ruv, replicacsn); /* too much skew */
if (rc == CSN_LIMIT_EXCEEDED)
{
- extern int config_get_ignore_time_skew();
-
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"conn=%" NSPRIu64 " op=%d repl=\"%s\": "
"Excessive clock skew from supplier RUV\n",
(long long unsigned int)connid, opid, repl_root);
- if (!config_get_ignore_time_skew()) {
- response = NSDS50_REPL_EXCESSIVE_CLOCK_SKEW;
- goto send_response;
- } else {
- /* else just continue */
- rc = 0;
- }
+ response = NSDS50_REPL_EXCESSIVE_CLOCK_SKEW;
+ goto send_response;
}
else if (rc != 0)
{
diff --git a/ldap/servers/slapd/csngen.c b/ldap/servers/slapd/csngen.c
index 464a59e..f87f2d1 100644
--- a/ldap/servers/slapd/csngen.c
+++ b/ldap/servers/slapd/csngen.c
@@ -326,6 +326,8 @@ int csngen_adjust_time(CSNGen *gen, const CSN* csn)
time_t remote_time, remote_offset, cur_time;
PRUint16 remote_seqnum;
int rc;
+ extern int config_get_ignore_time_skew();
+ int ignore_time_skew = config_get_ignore_time_skew();
if (gen == NULL || csn == NULL)
return CSN_INVALID_PARAMETER;
@@ -380,7 +382,7 @@ int csngen_adjust_time(CSNGen *gen, const CSN* csn)
remote_offset = remote_time - cur_time;
if (remote_offset > gen->state.remote_offset)
{
- if (remote_offset <= CSN_MAX_TIME_ADJUST)
+ if (ignore_time_skew || (remote_offset <= CSN_MAX_TIME_ADJUST))
{
gen->state.remote_offset = remote_offset;
}
@@ -651,6 +653,8 @@ _csngen_cmp_callbacks (const void *el1, const void *el2)
static int
_csngen_adjust_local_time (CSNGen *gen, time_t cur_time)
{
+ extern int config_get_ignore_time_skew();
+ int ignore_time_skew = config_get_ignore_time_skew();
time_t time_diff = cur_time - gen->state.sampled_time;
if (time_diff == 0) {
@@ -714,7 +718,7 @@ _csngen_adjust_local_time (CSNGen *gen, time_t cur_time)
gen->state.remote_offset);
}
- if (abs (time_diff) > CSN_MAX_TIME_ADJUST)
+ if (!ignore_time_skew && (abs (time_diff) > CSN_MAX_TIME_ADJUST))
{
slapi_log_error (SLAPI_LOG_FATAL, NULL, "_csngen_adjust_local_time: "
"adjustment limit exceeded; value - %d, limit - %d\n",
10 years, 2 months
Branch '389-ds-base-1.3.0' - ldap/servers
by Richard Allen Megginson
ldap/servers/plugins/replication/repl_extop.c | 11 ++---------
ldap/servers/slapd/csngen.c | 8 ++++++--
2 files changed, 8 insertions(+), 11 deletions(-)
New commits:
commit b51a57b20386e506a7eb484b62d39bf249ef995f
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu Jan 16 12:57:22 2014 -0700
Ticket #47516 replication stops with excessive clock skew
https://fedorahosted.org/389/ticket/47516
Reviewed by: nhosoi (Thanks!)
Branch: 389-ds-base-1.3.1
Fix Description: The previous fix was not adequate. Instead, the determination
of whether or not to ignore time skew should be determined in
csngen_adjust_time().
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: yes - document new config param
(cherry picked from commit 9f2b104b0938b21d7c9fe37c736d0e6328843aeb)
(cherry picked from commit a6ec074c6295a59938f313b4fe09430e8f601fab)
diff --git a/ldap/servers/plugins/replication/repl_extop.c b/ldap/servers/plugins/replication/repl_extop.c
index e7f33f9..4b4dd2c 100644
--- a/ldap/servers/plugins/replication/repl_extop.c
+++ b/ldap/servers/plugins/replication/repl_extop.c
@@ -835,19 +835,12 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
rc = replica_update_csngen_state_ext (replica, supplier_ruv, replicacsn); /* too much skew */
if (rc == CSN_LIMIT_EXCEEDED)
{
- extern int config_get_ignore_time_skew();
-
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"conn=%" NSPRIu64 " op=%d repl=\"%s\": "
"Excessive clock skew from supplier RUV\n",
connid, opid, repl_root);
- if (!config_get_ignore_time_skew()) {
- response = NSDS50_REPL_EXCESSIVE_CLOCK_SKEW;
- goto send_response;
- } else {
- /* else just continue */
- rc = 0;
- }
+ response = NSDS50_REPL_EXCESSIVE_CLOCK_SKEW;
+ goto send_response;
}
else if (rc != 0)
{
diff --git a/ldap/servers/slapd/csngen.c b/ldap/servers/slapd/csngen.c
index 7e0bdb6..3ec7620 100644
--- a/ldap/servers/slapd/csngen.c
+++ b/ldap/servers/slapd/csngen.c
@@ -315,6 +315,8 @@ int csngen_adjust_time (CSNGen *gen, const CSN* csn)
time_t remote_time, remote_offset, cur_time;
PRUint16 remote_seqnum;
int rc;
+ extern int config_get_ignore_time_skew();
+ int ignore_time_skew = config_get_ignore_time_skew();
if (gen == NULL || csn == NULL)
return CSN_INVALID_PARAMETER;
@@ -369,7 +371,7 @@ int csngen_adjust_time (CSNGen *gen, const CSN* csn)
remote_offset = remote_time - cur_time;
if (remote_offset > gen->state.remote_offset)
{
- if (remote_offset <= CSN_MAX_TIME_ADJUST)
+ if (ignore_time_skew || (remote_offset <= CSN_MAX_TIME_ADJUST))
{
gen->state.remote_offset = remote_offset;
}
@@ -640,6 +642,8 @@ _csngen_cmp_callbacks (const void *el1, const void *el2)
static int
_csngen_adjust_local_time (CSNGen *gen, time_t cur_time)
{
+ extern int config_get_ignore_time_skew();
+ int ignore_time_skew = config_get_ignore_time_skew();
time_t time_diff = cur_time - gen->state.sampled_time;
if (time_diff == 0) {
@@ -703,7 +707,7 @@ _csngen_adjust_local_time (CSNGen *gen, time_t cur_time)
gen->state.remote_offset);
}
- if (abs (time_diff) > CSN_MAX_TIME_ADJUST)
+ if (!ignore_time_skew && (abs (time_diff) > CSN_MAX_TIME_ADJUST))
{
slapi_log_error (SLAPI_LOG_FATAL, NULL, "_csngen_adjust_local_time: "
"adjustment limit exceeded; value - %d, limit - %d\n",
10 years, 2 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Richard Allen Megginson
ldap/servers/plugins/replication/repl_extop.c | 11 ++---------
ldap/servers/slapd/csngen.c | 8 ++++++--
2 files changed, 8 insertions(+), 11 deletions(-)
New commits:
commit d128dbde4bff3d9c523d58b5ff485d052edbaf92
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Thu Jan 16 12:57:22 2014 -0700
Ticket #47516 replication stops with excessive clock skew
https://fedorahosted.org/389/ticket/47516
Reviewed by: nhosoi (Thanks!)
Branch: 389-ds-base-1.2.11
Fix Description: The previous fix was not adequate. Instead, the determination
of whether or not to ignore time skew should be determined in
csngen_adjust_time().
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: yes - document new config param
(cherry picked from commit 9f2b104b0938b21d7c9fe37c736d0e6328843aeb)
(cherry picked from commit a6ec074c6295a59938f313b4fe09430e8f601fab)
(cherry picked from commit b51a57b20386e506a7eb484b62d39bf249ef995f)
diff --git a/ldap/servers/plugins/replication/repl_extop.c b/ldap/servers/plugins/replication/repl_extop.c
index cccebb4..92207df 100644
--- a/ldap/servers/plugins/replication/repl_extop.c
+++ b/ldap/servers/plugins/replication/repl_extop.c
@@ -835,19 +835,12 @@ multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb)
rc = replica_update_csngen_state_ext (replica, supplier_ruv, replicacsn); /* too much skew */
if (rc == CSN_LIMIT_EXCEEDED)
{
- extern int config_get_ignore_time_skew();
-
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"conn=%" NSPRIu64 " op=%d repl=\"%s\": "
"Excessive clock skew from supplier RUV\n",
connid, opid, repl_root);
- if (!config_get_ignore_time_skew()) {
- response = NSDS50_REPL_EXCESSIVE_CLOCK_SKEW;
- goto send_response;
- } else {
- /* else just continue */
- rc = 0;
- }
+ response = NSDS50_REPL_EXCESSIVE_CLOCK_SKEW;
+ goto send_response;
}
else if (rc != 0)
{
diff --git a/ldap/servers/slapd/csngen.c b/ldap/servers/slapd/csngen.c
index 7e0bdb6..3ec7620 100644
--- a/ldap/servers/slapd/csngen.c
+++ b/ldap/servers/slapd/csngen.c
@@ -315,6 +315,8 @@ int csngen_adjust_time (CSNGen *gen, const CSN* csn)
time_t remote_time, remote_offset, cur_time;
PRUint16 remote_seqnum;
int rc;
+ extern int config_get_ignore_time_skew();
+ int ignore_time_skew = config_get_ignore_time_skew();
if (gen == NULL || csn == NULL)
return CSN_INVALID_PARAMETER;
@@ -369,7 +371,7 @@ int csngen_adjust_time (CSNGen *gen, const CSN* csn)
remote_offset = remote_time - cur_time;
if (remote_offset > gen->state.remote_offset)
{
- if (remote_offset <= CSN_MAX_TIME_ADJUST)
+ if (ignore_time_skew || (remote_offset <= CSN_MAX_TIME_ADJUST))
{
gen->state.remote_offset = remote_offset;
}
@@ -640,6 +642,8 @@ _csngen_cmp_callbacks (const void *el1, const void *el2)
static int
_csngen_adjust_local_time (CSNGen *gen, time_t cur_time)
{
+ extern int config_get_ignore_time_skew();
+ int ignore_time_skew = config_get_ignore_time_skew();
time_t time_diff = cur_time - gen->state.sampled_time;
if (time_diff == 0) {
@@ -703,7 +707,7 @@ _csngen_adjust_local_time (CSNGen *gen, time_t cur_time)
gen->state.remote_offset);
}
- if (abs (time_diff) > CSN_MAX_TIME_ADJUST)
+ if (!ignore_time_skew && (abs (time_diff) > CSN_MAX_TIME_ADJUST))
{
slapi_log_error (SLAPI_LOG_FATAL, NULL, "_csngen_adjust_local_time: "
"adjustment limit exceeded; value - %d, limit - %d\n",
10 years, 2 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/replication/repl5.h | 1
ldap/servers/plugins/replication/repl5_agmtlist.c | 46 ++++++++++------------
ldap/servers/plugins/replication/repl_globals.c | 1
3 files changed, 22 insertions(+), 26 deletions(-)
New commits:
commit 77380161e9e04f64a431dd35ce4b4c45ed01cae5
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jan 17 15:13:21 2014 -0500
Ticket 47620 - Unable to delete protocol timeout attribute
Bug Description: Attempting to delete nsds5ReplicaProtocolTimeout from a replication
agreement unexpectedly fails with an error 53.
Fix Description: The previous delete operation check was in the wrong location, and the
delete operation was treated as a modify - which then triggered the
error 53. Added the correct check for the delete operation.
Also removed some old code for a CLEANALLRUV attribute that was never
implemented.
https://fedorahosted.org/389/ticket/47620
Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 9c41a365e8fbd23cab28eb91f50cdce696a30730)
diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h
index 321a285..655e8ba 100644
--- a/ldap/servers/plugins/replication/repl5.h
+++ b/ldap/servers/plugins/replication/repl5.h
@@ -167,7 +167,6 @@ extern const char *type_nsds5ReplicaBusyWaitTime;
extern const char *type_nsds5ReplicaSessionPauseTime;
extern const char *type_nsds5ReplicaEnabled;
extern const char *type_nsds5ReplicaStripAttrs;
-extern const char *type_nsds5ReplicaCleanRUVnotified;
extern const char *type_replicaProtocolTimeout;
extern const char *type_replicaBackoffMin;
extern const char *type_replicaBackoffMax;
diff --git a/ldap/servers/plugins/replication/repl5_agmtlist.c b/ldap/servers/plugins/replication/repl5_agmtlist.c
index 9e0291f..0edf28a 100644
--- a/ldap/servers/plugins/replication/repl5_agmtlist.c
+++ b/ldap/servers/plugins/replication/repl5_agmtlist.c
@@ -254,15 +254,6 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
the replication plugin - handled above */
if (mods[i]->mod_op & LDAP_MOD_DELETE)
{
- if(strcasecmp (mods[i]->mod_type, type_nsds5ReplicaCleanRUVnotified) == 0 ){
- /* allow the deletion of cleanallruv agmt attr */
- continue;
- }
- if(strcasecmp (mods[i]->mod_type, type_replicaProtocolTimeout) == 0){
- agmt_set_protocol_timeout(agmt, 0);
- continue;
- }
-
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "agmtlist_modify_callback: "
"deletion of %s attribute is not allowed\n", type_nsds5ReplicaInitialize);
*returncode = LDAP_UNWILLING_TO_PERFORM;
@@ -505,23 +496,30 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
}
}
else if (slapi_attr_types_equivalent(mods[i]->mod_type, type_replicaProtocolTimeout)){
- long ptimeout = 0;
-
- if (val){
- ptimeout = atol(val);
+ if (mods[i]->mod_op & LDAP_MOD_DELETE)
+ {
+ agmt_set_protocol_timeout(agmt, 0);
}
- if(ptimeout <= 0){
- *returncode = LDAP_UNWILLING_TO_PERFORM;
- PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE,
- "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
- type_replicaProtocolTimeout, val ? val : "");
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "attribute %s value (%s) is invalid, "
- "must be a number greater than zero.\n",
- type_replicaProtocolTimeout, val ? val : "");
- rc = SLAPI_DSE_CALLBACK_ERROR;
- break;
+ else
+ {
+ long ptimeout = 0;
+
+ if (val){
+ ptimeout = atol(val);
+ }
+ if(ptimeout <= 0){
+ *returncode = LDAP_UNWILLING_TO_PERFORM;
+ PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
+ type_replicaProtocolTimeout, val ? val : "");
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "attribute %s value (%s) is invalid, "
+ "must be a number greater than zero.\n",
+ type_replicaProtocolTimeout, val ? val : "");
+ rc = SLAPI_DSE_CALLBACK_ERROR;
+ break;
+ }
+ agmt_set_protocol_timeout(agmt, ptimeout);
}
- agmt_set_protocol_timeout(agmt, ptimeout);
}
else if (0 == windows_handle_modify_agreement(agmt, mods[i]->mod_type, e))
{
diff --git a/ldap/servers/plugins/replication/repl_globals.c b/ldap/servers/plugins/replication/repl_globals.c
index 7dfeb9b..305ed25 100644
--- a/ldap/servers/plugins/replication/repl_globals.c
+++ b/ldap/servers/plugins/replication/repl_globals.c
@@ -133,7 +133,6 @@ const char *type_nsds5ReplicaBusyWaitTime = "nsds5ReplicaBusyWaitTime";
const char *type_nsds5ReplicaSessionPauseTime = "nsds5ReplicaSessionPauseTime";
const char *type_nsds5ReplicaEnabled = "nsds5ReplicaEnabled";
const char *type_nsds5ReplicaStripAttrs = "nsds5ReplicaStripAttrs";
-const char *type_nsds5ReplicaCleanRUVnotified = "nsds5ReplicaCleanRUVNotified";
/* windows sync specific attributes */
const char *type_nsds7WindowsReplicaArea = "nsds7WindowsReplicaSubtree";
10 years, 2 months
Branch '389-ds-base-1.3.2' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/replication/repl5.h | 1
ldap/servers/plugins/replication/repl5_agmtlist.c | 46 ++++++++++------------
ldap/servers/plugins/replication/repl_globals.c | 1
3 files changed, 22 insertions(+), 26 deletions(-)
New commits:
commit 668903ca6cccf3686ab8d018f87fee8bad08a738
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jan 17 15:13:21 2014 -0500
Ticket 47620 - Unable to delete protocol timeout attribute
Bug Description: Attempting to delete nsds5ReplicaProtocolTimeout from a replication
agreement unexpectedly fails with an error 53.
Fix Description: The previous delete operation check was in the wrong location, and the
delete operation was treated as a modify - which then triggered the
error 53. Added the correct check for the delete operation.
Also removed some old code for a CLEANALLRUV attribute that was never
implemented.
https://fedorahosted.org/389/ticket/47620
Reviewed by: nhosoi(Thanks!)
(cherry picked from commit 9c41a365e8fbd23cab28eb91f50cdce696a30730)
diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h
index 988feca..5383204 100644
--- a/ldap/servers/plugins/replication/repl5.h
+++ b/ldap/servers/plugins/replication/repl5.h
@@ -167,7 +167,6 @@ extern const char *type_nsds5ReplicaBusyWaitTime;
extern const char *type_nsds5ReplicaSessionPauseTime;
extern const char *type_nsds5ReplicaEnabled;
extern const char *type_nsds5ReplicaStripAttrs;
-extern const char *type_nsds5ReplicaCleanRUVnotified;
extern const char *type_replicaProtocolTimeout;
extern const char *type_replicaBackoffMin;
extern const char *type_replicaBackoffMax;
diff --git a/ldap/servers/plugins/replication/repl5_agmtlist.c b/ldap/servers/plugins/replication/repl5_agmtlist.c
index c88123a..1cf2976 100644
--- a/ldap/servers/plugins/replication/repl5_agmtlist.c
+++ b/ldap/servers/plugins/replication/repl5_agmtlist.c
@@ -254,15 +254,6 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
the replication plugin - handled above */
if (mods[i]->mod_op & LDAP_MOD_DELETE)
{
- if(strcasecmp (mods[i]->mod_type, type_nsds5ReplicaCleanRUVnotified) == 0 ){
- /* allow the deletion of cleanallruv agmt attr */
- continue;
- }
- if(strcasecmp (mods[i]->mod_type, type_replicaProtocolTimeout) == 0){
- agmt_set_protocol_timeout(agmt, 0);
- continue;
- }
-
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "agmtlist_modify_callback: "
"deletion of %s attribute is not allowed\n", type_nsds5ReplicaInitialize);
*returncode = LDAP_UNWILLING_TO_PERFORM;
@@ -508,23 +499,30 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
}
}
else if (slapi_attr_types_equivalent(mods[i]->mod_type, type_replicaProtocolTimeout)){
- long ptimeout = 0;
-
- if (val){
- ptimeout = atol(val);
+ if (mods[i]->mod_op & LDAP_MOD_DELETE)
+ {
+ agmt_set_protocol_timeout(agmt, 0);
}
- if(ptimeout <= 0){
- *returncode = LDAP_UNWILLING_TO_PERFORM;
- PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE,
- "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
- type_replicaProtocolTimeout, val ? val : "");
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "attribute %s value (%s) is invalid, "
- "must be a number greater than zero.\n",
- type_replicaProtocolTimeout, val ? val : "");
- rc = SLAPI_DSE_CALLBACK_ERROR;
- break;
+ else
+ {
+ long ptimeout = 0;
+
+ if (val){
+ ptimeout = atol(val);
+ }
+ if(ptimeout <= 0){
+ *returncode = LDAP_UNWILLING_TO_PERFORM;
+ PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
+ type_replicaProtocolTimeout, val ? val : "");
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "attribute %s value (%s) is invalid, "
+ "must be a number greater than zero.\n",
+ type_replicaProtocolTimeout, val ? val : "");
+ rc = SLAPI_DSE_CALLBACK_ERROR;
+ break;
+ }
+ agmt_set_protocol_timeout(agmt, ptimeout);
}
- agmt_set_protocol_timeout(agmt, ptimeout);
}
else if (0 == windows_handle_modify_agreement(agmt, mods[i]->mod_type, e))
{
diff --git a/ldap/servers/plugins/replication/repl_globals.c b/ldap/servers/plugins/replication/repl_globals.c
index c0b8712..007dd28 100644
--- a/ldap/servers/plugins/replication/repl_globals.c
+++ b/ldap/servers/plugins/replication/repl_globals.c
@@ -133,7 +133,6 @@ const char *type_nsds5ReplicaBusyWaitTime = "nsds5ReplicaBusyWaitTime";
const char *type_nsds5ReplicaSessionPauseTime = "nsds5ReplicaSessionPauseTime";
const char *type_nsds5ReplicaEnabled = "nsds5ReplicaEnabled";
const char *type_nsds5ReplicaStripAttrs = "nsds5ReplicaStripAttrs";
-const char *type_nsds5ReplicaCleanRUVnotified = "nsds5ReplicaCleanRUVNotified";
/* windows sync specific attributes */
const char *type_nsds7WindowsReplicaArea = "nsds7WindowsReplicaSubtree";
10 years, 2 months
ldap/servers
by Mark Reynolds
ldap/servers/plugins/replication/repl5.h | 1
ldap/servers/plugins/replication/repl5_agmtlist.c | 46 ++++++++++------------
ldap/servers/plugins/replication/repl_globals.c | 1
3 files changed, 22 insertions(+), 26 deletions(-)
New commits:
commit 9c41a365e8fbd23cab28eb91f50cdce696a30730
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Jan 17 15:13:21 2014 -0500
Ticket 47620 - Unable to delete protocol timeout attribute
Bug Description: Attempting to delete nsds5ReplicaProtocolTimeout from a replication
agreement unexpectedly fails with an error 53.
Fix Description: The previous delete operation check was in the wrong location, and the
delete operation was treated as a modify - which then triggered the
error 53. Added the correct check for the delete operation.
Also removed some old code for a CLEANALLRUV attribute that was never
implemented.
https://fedorahosted.org/389/ticket/47620
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/plugins/replication/repl5.h b/ldap/servers/plugins/replication/repl5.h
index 49d83d5..716da32 100644
--- a/ldap/servers/plugins/replication/repl5.h
+++ b/ldap/servers/plugins/replication/repl5.h
@@ -167,7 +167,6 @@ extern const char *type_nsds5ReplicaBusyWaitTime;
extern const char *type_nsds5ReplicaSessionPauseTime;
extern const char *type_nsds5ReplicaEnabled;
extern const char *type_nsds5ReplicaStripAttrs;
-extern const char *type_nsds5ReplicaCleanRUVnotified;
extern const char *type_replicaProtocolTimeout;
extern const char *type_replicaBackoffMin;
extern const char *type_replicaBackoffMax;
diff --git a/ldap/servers/plugins/replication/repl5_agmtlist.c b/ldap/servers/plugins/replication/repl5_agmtlist.c
index 334f8a1..53c12a9 100644
--- a/ldap/servers/plugins/replication/repl5_agmtlist.c
+++ b/ldap/servers/plugins/replication/repl5_agmtlist.c
@@ -254,15 +254,6 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
the replication plugin - handled above */
if (mods[i]->mod_op & LDAP_MOD_DELETE)
{
- if(strcasecmp (mods[i]->mod_type, type_nsds5ReplicaCleanRUVnotified) == 0 ){
- /* allow the deletion of cleanallruv agmt attr */
- continue;
- }
- if(strcasecmp (mods[i]->mod_type, type_replicaProtocolTimeout) == 0){
- agmt_set_protocol_timeout(agmt, 0);
- continue;
- }
-
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "agmtlist_modify_callback: "
"deletion of %s attribute is not allowed\n", type_nsds5ReplicaInitialize);
*returncode = LDAP_UNWILLING_TO_PERFORM;
@@ -514,23 +505,30 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
}
}
else if (slapi_attr_types_equivalent(mods[i]->mod_type, type_replicaProtocolTimeout)){
- long ptimeout = 0;
-
- if (val){
- ptimeout = atol(val);
+ if (mods[i]->mod_op & LDAP_MOD_DELETE)
+ {
+ agmt_set_protocol_timeout(agmt, 0);
}
- if(ptimeout <= 0){
- *returncode = LDAP_UNWILLING_TO_PERFORM;
- PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE,
- "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
- type_replicaProtocolTimeout, val ? val : "");
- slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "attribute %s value (%s) is invalid, "
- "must be a number greater than zero.\n",
- type_replicaProtocolTimeout, val ? val : "");
- rc = SLAPI_DSE_CALLBACK_ERROR;
- break;
+ else
+ {
+ long ptimeout = 0;
+
+ if (val){
+ ptimeout = atol(val);
+ }
+ if(ptimeout <= 0){
+ *returncode = LDAP_UNWILLING_TO_PERFORM;
+ PR_snprintf (returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+ "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
+ type_replicaProtocolTimeout, val ? val : "");
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "attribute %s value (%s) is invalid, "
+ "must be a number greater than zero.\n",
+ type_replicaProtocolTimeout, val ? val : "");
+ rc = SLAPI_DSE_CALLBACK_ERROR;
+ break;
+ }
+ agmt_set_protocol_timeout(agmt, ptimeout);
}
- agmt_set_protocol_timeout(agmt, ptimeout);
}
else if (0 == windows_handle_modify_agreement(agmt, mods[i]->mod_type, e))
{
diff --git a/ldap/servers/plugins/replication/repl_globals.c b/ldap/servers/plugins/replication/repl_globals.c
index ee09e49..68891a1 100644
--- a/ldap/servers/plugins/replication/repl_globals.c
+++ b/ldap/servers/plugins/replication/repl_globals.c
@@ -134,7 +134,6 @@ const char *type_nsds5ReplicaBusyWaitTime = "nsds5ReplicaBusyWaitTime";
const char *type_nsds5ReplicaSessionPauseTime = "nsds5ReplicaSessionPauseTime";
const char *type_nsds5ReplicaEnabled = "nsds5ReplicaEnabled";
const char *type_nsds5ReplicaStripAttrs = "nsds5ReplicaStripAttrs";
-const char *type_nsds5ReplicaCleanRUVnotified = "nsds5ReplicaCleanRUVNotified";
/* windows sync specific attributes */
const char *type_nsds7WindowsReplicaArea = "nsds7WindowsReplicaSubtree";
10 years, 2 months
Branch '389-ds-base-1.3.0' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/back-ldbm/monitor.c | 2
ldap/servers/slapd/dn.c | 93 ++++++++++++++++++++++++++-------
ldap/servers/slapd/main.c | 1
ldap/servers/slapd/slapi-private.h | 2
4 files changed, 78 insertions(+), 20 deletions(-)
New commits:
commit 075a54e80fb99eb0d21f9c6fb45bc4a6d3ade6bd
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Jan 16 15:21:28 2014 -0500
Ticket 408 - Fix crash when disabling/enabling the setting
Bug Description: Enabling/disabling can lead to crash as the setting
was not designed to be dynamically updated.
Fix Description: Do not use the actual config setting to determine if the
cache is enabled. Instead we record when the cache is
initialized. The server still needs to be restarted for
the config change to take effect.
Also freed the cache at server shtudown.
https://fedorahosted.org/389/ticket/408
Reviewed by: rmeggins(Thanks!)
(cherry picked from commit 03c90f04065059ee310e9fa7d98228e0aa39fa50)
(cherry picked from commit 50ad64a442495810a84558c6c17dcc2263b815b6)
(cherry picked from commit e0d85bead832c6aa7a2ec01157ab786a53fb5272)
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
index 49edb68..1bb0f77 100644
--- a/ldap/servers/slapd/back-ldbm/monitor.c
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
@@ -146,7 +146,7 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
MSET("maxDnCacheCount");
}
/* normalized dn cache stats */
- if(config_get_ndn_cache_enabled()){
+ if(ndn_cache_started()){
ndn_cache_get_stats(&hits, &tries, &size, &maxsize, &count);
sprintf(buf, "%" NSPRIu64, tries);
MSET("normalizedDnCacheTries");
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index 074f0a3..d951c0c 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -103,6 +103,7 @@ static void ndn_cache_update_lru(struct ndn_cache_lru **node);
static void ndn_cache_add(char *dn, size_t dn_len, char *ndn, size_t ndn_len);
static void ndn_cache_delete(char *dn);
static void ndn_cache_flush();
+static void ndn_cache_free();
static int ndn_started = 0;
static PRLock *lru_lock = NULL;
static Slapi_RWLock *ndn_cache_lock = NULL;
@@ -2704,7 +2705,7 @@ ndn_hash_string(const void *key)
void
ndn_cache_init()
{
- if(!config_get_ndn_cache_enabled()){
+ if(!config_get_ndn_cache_enabled() || ndn_started){
return;
}
ndn_cache_hashtable = PL_NewHashTable( NDN_CACHE_BUCKETS, ndn_hash_string, PL_CompareStrings, PL_CompareValues, 0, 0);
@@ -2717,24 +2718,49 @@ ndn_cache_init()
ndn_cache->cache_size = sizeof(struct ndn_cache_ctx) + sizeof(PLHashTable) + sizeof(PLHashTable);
ndn_cache->head = NULL;
ndn_cache->tail = NULL;
-
+ ndn_started = 1;
if ( NULL == ( lru_lock = PR_NewLock()) || NULL == ( ndn_cache_lock = slapi_new_rwlock())) {
- char *errorbuf = NULL;
- if(ndn_cache_hashtable){
- PL_HashTableDestroy(ndn_cache_hashtable);
- }
- ndn_cache_hashtable = NULL;
- config_set_ndn_cache_enabled(CONFIG_NDN_CACHE, "off", errorbuf, 1 );
- slapi_counter_destroy(&ndn_cache->cache_hits);
- slapi_counter_destroy(&ndn_cache->cache_tries);
- slapi_counter_destroy(&ndn_cache->cache_misses);
- slapi_ch_free((void **)&ndn_cache);
+ ndn_cache_destroy();
slapi_log_error( SLAPI_LOG_FATAL, "ndn_cache_init", "Failed to create locks. Disabling cache.\n" );
- } else {
- ndn_started = 1;
}
}
+void
+ndn_cache_destroy()
+{
+ char *errorbuf = NULL;
+
+ if(!ndn_started){
+ return;
+ }
+ if(lru_lock){
+ PR_DestroyLock(lru_lock);
+ lru_lock = NULL;
+ }
+ if(ndn_cache_lock){
+ slapi_destroy_rwlock(ndn_cache_lock);
+ ndn_cache_lock = NULL;
+ }
+ if(ndn_cache_hashtable){
+ ndn_cache_free();
+ PL_HashTableDestroy(ndn_cache_hashtable);
+ ndn_cache_hashtable = NULL;
+ }
+ config_set_ndn_cache_enabled(CONFIG_NDN_CACHE, "off", errorbuf, 1 );
+ slapi_counter_destroy(&ndn_cache->cache_hits);
+ slapi_counter_destroy(&ndn_cache->cache_tries);
+ slapi_counter_destroy(&ndn_cache->cache_misses);
+ slapi_ch_free((void **)&ndn_cache);
+
+ ndn_started = 0;
+}
+
+int
+ndn_cache_started()
+{
+ return ndn_started;
+}
+
/*
* Look up this dn in the ndn cache
*/
@@ -2944,19 +2970,48 @@ ndn_cache_flush()
slapi_log_error( SLAPI_LOG_CACHE, "ndn_cache_flush","Flushed cache.\n");
}
+static void
+ndn_cache_free()
+{
+ struct ndn_cache_lru *node, *next, *flush_node;
+
+ if(!ndn_cache){
+ return;
+ }
+
+ node = ndn_cache->tail;
+ while(ndn_cache->cache_count){
+ flush_node = node;
+ /* update the lru */
+ next = node->prev;
+ if(next){
+ next->next = NULL;
+ }
+ ndn_cache->tail = next;
+ node = next;
+ /* now update the hash */
+ ndn_cache->cache_count--;
+ ndn_cache_delete(flush_node->key);
+ slapi_ch_free_string(&flush_node->key);
+ slapi_ch_free((void **)&flush_node);
+ }
+}
+
/* this is already "write" locked from ndn_cache_add */
static void
ndn_cache_delete(char *dn)
{
- struct ndn_hash_val *ht_val;
+ struct ndn_hash_val *ht_entry;
- ht_val = (struct ndn_hash_val *)PL_HashTableLookupConst(ndn_cache_hashtable, dn);
- if(ht_val){
- ndn_cache->cache_size -= ht_val->size;
- slapi_ch_free_string(&ht_val->ndn);
+ ht_entry = (struct ndn_hash_val *)PL_HashTableLookupConst(ndn_cache_hashtable, dn);
+ if(ht_entry){
+ ndn_cache->cache_size -= ht_entry->size;
+ slapi_ch_free_string(&ht_entry->ndn);
+ slapi_ch_free((void **)&ht_entry);
PL_HashTableRemove(ndn_cache_hashtable, dn);
}
}
+
/* stats for monitor */
void
ndn_cache_get_stats(PRUint64 *hits, PRUint64 *tries, size_t *size, size_t *max_size, long *count)
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index fdee5d2..4d510cb 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -1279,6 +1279,7 @@ main( int argc, char **argv)
cleanup:
SSL_ShutdownServerSessionIDCache();
SSL_ClearSessionCache();
+ ndn_cache_destroy();
NSS_Shutdown();
PR_Cleanup();
#ifdef _WIN32
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index 9f1bc25..ac40407 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -388,6 +388,8 @@ Slapi_DN *slapi_sdn_init_normdn_passin(Slapi_DN *sdn, const char *dn);
char *slapi_dn_normalize_original( char *dn );
char *slapi_dn_normalize_case_original( char *dn );
void ndn_cache_init();
+void ndn_cache_destroy();
+int ndn_cache_started();
void ndn_cache_get_stats(PRUint64 *hits, PRUint64 *tries, size_t *size, size_t *max_size, long *count);
#define NDN_DEFAULT_SIZE 20971520 /* 20mb - size of normalized dn cache */
10 years, 2 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/back-ldbm/monitor.c | 2
ldap/servers/slapd/dn.c | 93 ++++++++++++++++++++++++++-------
ldap/servers/slapd/main.c | 1
ldap/servers/slapd/slapi-private.h | 2
4 files changed, 78 insertions(+), 20 deletions(-)
New commits:
commit e0d85bead832c6aa7a2ec01157ab786a53fb5272
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Jan 16 15:21:28 2014 -0500
Ticket 408 - Fix crash when disabling/enabling the setting
Bug Description: Enabling/disabling can lead to crash as the setting
was not designed to be dynamically updated.
Fix Description: Do not use the actual config setting to determine if the
cache is enabled. Instead we record when the cache is
initialized. The server still needs to be restarted for
the config change to take effect.
Also freed the cache at server shtudown.
https://fedorahosted.org/389/ticket/408
Reviewed by: rmeggins(Thanks!)
(cherry picked from commit 03c90f04065059ee310e9fa7d98228e0aa39fa50)
(cherry picked from commit 50ad64a442495810a84558c6c17dcc2263b815b6)
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
index 3427809..409c771 100644
--- a/ldap/servers/slapd/back-ldbm/monitor.c
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
@@ -146,7 +146,7 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
MSET("maxDnCacheCount");
}
/* normalized dn cache stats */
- if(config_get_ndn_cache_enabled()){
+ if(ndn_cache_started()){
ndn_cache_get_stats(&hits, &tries, &size, &maxsize, &count);
sprintf(buf, "%" NSPRIu64, (long long unsigned int)tries);
MSET("normalizedDnCacheTries");
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index 9530b84..1eab631 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -103,6 +103,7 @@ static void ndn_cache_update_lru(struct ndn_cache_lru **node);
static void ndn_cache_add(char *dn, size_t dn_len, char *ndn, size_t ndn_len);
static void ndn_cache_delete(char *dn);
static void ndn_cache_flush();
+static void ndn_cache_free();
static int ndn_started = 0;
static PRLock *lru_lock = NULL;
static Slapi_RWLock *ndn_cache_lock = NULL;
@@ -2751,7 +2752,7 @@ ndn_hash_string(const void *key)
void
ndn_cache_init()
{
- if(!config_get_ndn_cache_enabled()){
+ if(!config_get_ndn_cache_enabled() || ndn_started){
return;
}
ndn_cache_hashtable = PL_NewHashTable( NDN_CACHE_BUCKETS, ndn_hash_string, PL_CompareStrings, PL_CompareValues, 0, 0);
@@ -2764,24 +2765,49 @@ ndn_cache_init()
ndn_cache->cache_size = sizeof(struct ndn_cache_ctx) + sizeof(PLHashTable) + sizeof(PLHashTable);
ndn_cache->head = NULL;
ndn_cache->tail = NULL;
-
+ ndn_started = 1;
if ( NULL == ( lru_lock = PR_NewLock()) || NULL == ( ndn_cache_lock = slapi_new_rwlock())) {
- char *errorbuf = NULL;
- if(ndn_cache_hashtable){
- PL_HashTableDestroy(ndn_cache_hashtable);
- }
- ndn_cache_hashtable = NULL;
- config_set_ndn_cache_enabled(CONFIG_NDN_CACHE, "off", errorbuf, 1 );
- slapi_counter_destroy(&ndn_cache->cache_hits);
- slapi_counter_destroy(&ndn_cache->cache_tries);
- slapi_counter_destroy(&ndn_cache->cache_misses);
- slapi_ch_free((void **)&ndn_cache);
+ ndn_cache_destroy();
slapi_log_error( SLAPI_LOG_FATAL, "ndn_cache_init", "Failed to create locks. Disabling cache.\n" );
- } else {
- ndn_started = 1;
}
}
+void
+ndn_cache_destroy()
+{
+ char *errorbuf = NULL;
+
+ if(!ndn_started){
+ return;
+ }
+ if(lru_lock){
+ PR_DestroyLock(lru_lock);
+ lru_lock = NULL;
+ }
+ if(ndn_cache_lock){
+ slapi_destroy_rwlock(ndn_cache_lock);
+ ndn_cache_lock = NULL;
+ }
+ if(ndn_cache_hashtable){
+ ndn_cache_free();
+ PL_HashTableDestroy(ndn_cache_hashtable);
+ ndn_cache_hashtable = NULL;
+ }
+ config_set_ndn_cache_enabled(CONFIG_NDN_CACHE, "off", errorbuf, 1 );
+ slapi_counter_destroy(&ndn_cache->cache_hits);
+ slapi_counter_destroy(&ndn_cache->cache_tries);
+ slapi_counter_destroy(&ndn_cache->cache_misses);
+ slapi_ch_free((void **)&ndn_cache);
+
+ ndn_started = 0;
+}
+
+int
+ndn_cache_started()
+{
+ return ndn_started;
+}
+
/*
* Look up this dn in the ndn cache
*/
@@ -2994,19 +3020,48 @@ ndn_cache_flush()
slapi_log_error( SLAPI_LOG_CACHE, "ndn_cache_flush","Flushed cache.\n");
}
+static void
+ndn_cache_free()
+{
+ struct ndn_cache_lru *node, *next, *flush_node;
+
+ if(!ndn_cache){
+ return;
+ }
+
+ node = ndn_cache->tail;
+ while(ndn_cache->cache_count){
+ flush_node = node;
+ /* update the lru */
+ next = node->prev;
+ if(next){
+ next->next = NULL;
+ }
+ ndn_cache->tail = next;
+ node = next;
+ /* now update the hash */
+ ndn_cache->cache_count--;
+ ndn_cache_delete(flush_node->key);
+ slapi_ch_free_string(&flush_node->key);
+ slapi_ch_free((void **)&flush_node);
+ }
+}
+
/* this is already "write" locked from ndn_cache_add */
static void
ndn_cache_delete(char *dn)
{
- struct ndn_hash_val *ht_val;
+ struct ndn_hash_val *ht_entry;
- ht_val = (struct ndn_hash_val *)PL_HashTableLookupConst(ndn_cache_hashtable, dn);
- if(ht_val){
- ndn_cache->cache_size -= ht_val->size;
- slapi_ch_free_string(&ht_val->ndn);
+ ht_entry = (struct ndn_hash_val *)PL_HashTableLookupConst(ndn_cache_hashtable, dn);
+ if(ht_entry){
+ ndn_cache->cache_size -= ht_entry->size;
+ slapi_ch_free_string(&ht_entry->ndn);
+ slapi_ch_free((void **)&ht_entry);
PL_HashTableRemove(ndn_cache_hashtable, dn);
}
}
+
/* stats for monitor */
void
ndn_cache_get_stats(PRUint64 *hits, PRUint64 *tries, size_t *size, size_t *max_size, long *count)
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index a17a2c5..ad8dd83 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -1280,6 +1280,7 @@ main( int argc, char **argv)
cleanup:
SSL_ShutdownServerSessionIDCache();
SSL_ClearSessionCache();
+ ndn_cache_destroy();
NSS_Shutdown();
PR_Cleanup();
#ifdef _WIN32
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index 194f3fd..eaa5f98 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -392,6 +392,8 @@ Slapi_DN *slapi_sdn_init_normdn_passin(Slapi_DN *sdn, const char *dn);
char *slapi_dn_normalize_original( char *dn );
char *slapi_dn_normalize_case_original( char *dn );
void ndn_cache_init();
+void ndn_cache_destroy();
+int ndn_cache_started();
void ndn_cache_get_stats(PRUint64 *hits, PRUint64 *tries, size_t *size, size_t *max_size, long *count);
#define NDN_DEFAULT_SIZE 20971520 /* 20mb - size of normalized dn cache */
10 years, 2 months
Branch '389-ds-base-1.3.2' - ldap/servers
by Mark Reynolds
ldap/servers/slapd/back-ldbm/monitor.c | 2
ldap/servers/slapd/dn.c | 93 ++++++++++++++++++++++++++-------
ldap/servers/slapd/main.c | 1
ldap/servers/slapd/slapi-private.h | 2
4 files changed, 78 insertions(+), 20 deletions(-)
New commits:
commit 50ad64a442495810a84558c6c17dcc2263b815b6
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Jan 16 15:21:28 2014 -0500
Ticket 408 - Fix crash when disabling/enabling the setting
Bug Description: Enabling/disabling can lead to crash as the setting
was not designed to be dynamically updated.
Fix Description: Do not use the actual config setting to determine if the
cache is enabled. Instead we record when the cache is
initialized. The server still needs to be restarted for
the config change to take effect.
Also freed the cache at server shtudown.
https://fedorahosted.org/389/ticket/408
Reviewed by: rmeggins(Thanks!)
(cherry picked from commit 03c90f04065059ee310e9fa7d98228e0aa39fa50)
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
index 3427809..409c771 100644
--- a/ldap/servers/slapd/back-ldbm/monitor.c
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
@@ -146,7 +146,7 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
MSET("maxDnCacheCount");
}
/* normalized dn cache stats */
- if(config_get_ndn_cache_enabled()){
+ if(ndn_cache_started()){
ndn_cache_get_stats(&hits, &tries, &size, &maxsize, &count);
sprintf(buf, "%" NSPRIu64, (long long unsigned int)tries);
MSET("normalizedDnCacheTries");
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index b46a75b..e37f298 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -103,6 +103,7 @@ static void ndn_cache_update_lru(struct ndn_cache_lru **node);
static void ndn_cache_add(char *dn, size_t dn_len, char *ndn, size_t ndn_len);
static void ndn_cache_delete(char *dn);
static void ndn_cache_flush();
+static void ndn_cache_free();
static int ndn_started = 0;
static PRLock *lru_lock = NULL;
static Slapi_RWLock *ndn_cache_lock = NULL;
@@ -2776,7 +2777,7 @@ ndn_hash_string(const void *key)
void
ndn_cache_init()
{
- if(!config_get_ndn_cache_enabled()){
+ if(!config_get_ndn_cache_enabled() || ndn_started){
return;
}
ndn_cache_hashtable = PL_NewHashTable( NDN_CACHE_BUCKETS, ndn_hash_string, PL_CompareStrings, PL_CompareValues, 0, 0);
@@ -2789,24 +2790,49 @@ ndn_cache_init()
ndn_cache->cache_size = sizeof(struct ndn_cache_ctx) + sizeof(PLHashTable) + sizeof(PLHashTable);
ndn_cache->head = NULL;
ndn_cache->tail = NULL;
-
+ ndn_started = 1;
if ( NULL == ( lru_lock = PR_NewLock()) || NULL == ( ndn_cache_lock = slapi_new_rwlock())) {
- char *errorbuf = NULL;
- if(ndn_cache_hashtable){
- PL_HashTableDestroy(ndn_cache_hashtable);
- }
- ndn_cache_hashtable = NULL;
- config_set_ndn_cache_enabled(CONFIG_NDN_CACHE, "off", errorbuf, 1 );
- slapi_counter_destroy(&ndn_cache->cache_hits);
- slapi_counter_destroy(&ndn_cache->cache_tries);
- slapi_counter_destroy(&ndn_cache->cache_misses);
- slapi_ch_free((void **)&ndn_cache);
+ ndn_cache_destroy();
slapi_log_error( SLAPI_LOG_FATAL, "ndn_cache_init", "Failed to create locks. Disabling cache.\n" );
- } else {
- ndn_started = 1;
}
}
+void
+ndn_cache_destroy()
+{
+ char *errorbuf = NULL;
+
+ if(!ndn_started){
+ return;
+ }
+ if(lru_lock){
+ PR_DestroyLock(lru_lock);
+ lru_lock = NULL;
+ }
+ if(ndn_cache_lock){
+ slapi_destroy_rwlock(ndn_cache_lock);
+ ndn_cache_lock = NULL;
+ }
+ if(ndn_cache_hashtable){
+ ndn_cache_free();
+ PL_HashTableDestroy(ndn_cache_hashtable);
+ ndn_cache_hashtable = NULL;
+ }
+ config_set_ndn_cache_enabled(CONFIG_NDN_CACHE, "off", errorbuf, 1 );
+ slapi_counter_destroy(&ndn_cache->cache_hits);
+ slapi_counter_destroy(&ndn_cache->cache_tries);
+ slapi_counter_destroy(&ndn_cache->cache_misses);
+ slapi_ch_free((void **)&ndn_cache);
+
+ ndn_started = 0;
+}
+
+int
+ndn_cache_started()
+{
+ return ndn_started;
+}
+
/*
* Look up this dn in the ndn cache
*/
@@ -3019,19 +3045,48 @@ ndn_cache_flush()
slapi_log_error( SLAPI_LOG_CACHE, "ndn_cache_flush","Flushed cache.\n");
}
+static void
+ndn_cache_free()
+{
+ struct ndn_cache_lru *node, *next, *flush_node;
+
+ if(!ndn_cache){
+ return;
+ }
+
+ node = ndn_cache->tail;
+ while(ndn_cache->cache_count){
+ flush_node = node;
+ /* update the lru */
+ next = node->prev;
+ if(next){
+ next->next = NULL;
+ }
+ ndn_cache->tail = next;
+ node = next;
+ /* now update the hash */
+ ndn_cache->cache_count--;
+ ndn_cache_delete(flush_node->key);
+ slapi_ch_free_string(&flush_node->key);
+ slapi_ch_free((void **)&flush_node);
+ }
+}
+
/* this is already "write" locked from ndn_cache_add */
static void
ndn_cache_delete(char *dn)
{
- struct ndn_hash_val *ht_val;
+ struct ndn_hash_val *ht_entry;
- ht_val = (struct ndn_hash_val *)PL_HashTableLookupConst(ndn_cache_hashtable, dn);
- if(ht_val){
- ndn_cache->cache_size -= ht_val->size;
- slapi_ch_free_string(&ht_val->ndn);
+ ht_entry = (struct ndn_hash_val *)PL_HashTableLookupConst(ndn_cache_hashtable, dn);
+ if(ht_entry){
+ ndn_cache->cache_size -= ht_entry->size;
+ slapi_ch_free_string(&ht_entry->ndn);
+ slapi_ch_free((void **)&ht_entry);
PL_HashTableRemove(ndn_cache_hashtable, dn);
}
}
+
/* stats for monitor */
void
ndn_cache_get_stats(PRUint64 *hits, PRUint64 *tries, size_t *size, size_t *max_size, long *count)
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index f1812be..0c5b2ab 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -1280,6 +1280,7 @@ main( int argc, char **argv)
cleanup:
SSL_ShutdownServerSessionIDCache();
SSL_ClearSessionCache();
+ ndn_cache_destroy();
NSS_Shutdown();
PR_Cleanup();
#ifdef _WIN32
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index f459e9d..a0331bb 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -392,6 +392,8 @@ Slapi_DN *slapi_sdn_init_normdn_passin(Slapi_DN *sdn, const char *dn);
char *slapi_dn_normalize_original( char *dn );
char *slapi_dn_normalize_case_original( char *dn );
void ndn_cache_init();
+void ndn_cache_destroy();
+int ndn_cache_started();
void ndn_cache_get_stats(PRUint64 *hits, PRUint64 *tries, size_t *size, size_t *max_size, long *count);
#define NDN_DEFAULT_SIZE 20971520 /* 20mb - size of normalized dn cache */
10 years, 2 months