From d5312b2bd400695875c1fe68a6a54c612f09eec9 Mon Sep 17 00:00:00 2001 From: Rich Megginson <rmeggins@xxxxxxxxxx> Date: Tue, 15 Nov 2011 20:26:46 -0700 Subject: [PATCH] reduce calls to csn_as_string and slapi_log_error csn_as_string is an expensive operation - we should reduce calls to it many of these calls are in calls to slapi_log_error at the REPL log level where we want to print the csn string to the error log When we call slapi_log_error(REPL,...), any nested functions are called first, which means that even if the log level is REPL and nothing is logged, a lot of computation may occur for nothing. We should protect these calls using slapi_is_loglevel_set(). --- ldap/servers/plugins/replication/cl5_api.c | 147 ++++++++++++-------- ldap/servers/plugins/replication/csnpl.c | 6 +- .../plugins/replication/repl5_inc_protocol.c | 53 ++++---- ldap/servers/plugins/replication/repl5_plugins.c | 12 +- ldap/servers/plugins/replication/repl5_replica.c | 34 +++-- ldap/servers/plugins/replication/repl5_ruv.c | 41 ++++-- 6 files changed, 177 insertions(+), 116 deletions(-) diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c index 2a834d7..0ea90d1 100644 --- a/ldap/servers/plugins/replication/cl5_api.c +++ b/ldap/servers/plugins/replication/cl5_api.c @@ -3532,9 +3532,11 @@ static void _cl5TrimFile (Object *obj, long *numToTrim) } else { - slapi_log_error (SLAPI_LOG_REPL, NULL, - "Changelog purge skipped anchor csn %s\n", - csn_as_string (maxcsn, PR_FALSE, strCSN)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error (SLAPI_LOG_REPL, NULL, + "Changelog purge skipped anchor csn %s\n", + csn_as_string (maxcsn, PR_FALSE, strCSN)); + } /* extra read to skip the current record */ cl5_operation_parameters_done (&op); @@ -5020,10 +5022,13 @@ static int _cl5PositionCursorForReplay (ReplicaId consumerRID, const RUV *consum PR_ASSERT (supplierRuv); agmt_name = get_thread_private_agmtname(); - slapi_log_error(SLAPI_LOG_REPL, NULL, "_cl5PositionCursorForReplay (%s): Consumer RUV:\n", agmt_name); - ruv_dump (consumerRuv, agmt_name, NULL); - slapi_log_error(SLAPI_LOG_REPL, NULL, "_cl5PositionCursorForReplay (%s): Supplier RUV:\n", agmt_name); - ruv_dump (supplierRuv, agmt_name, NULL); + + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, NULL, "_cl5PositionCursorForReplay (%s): Consumer RUV:\n", agmt_name); + ruv_dump (consumerRuv, agmt_name, NULL); + slapi_log_error(SLAPI_LOG_REPL, NULL, "_cl5PositionCursorForReplay (%s): Supplier RUV:\n", agmt_name); + ruv_dump (supplierRuv, agmt_name, NULL); + } /* * get the sorted list of SupplierMinCSN (if no ConsumerMaxCSN) @@ -5054,7 +5059,6 @@ static int _cl5PositionCursorForReplay (ReplicaId consumerRID, const RUV *consum continue; startCSN = csns[i]; - csn_as_string(startCSN, PR_FALSE, csnStr); rc = clcache_get_buffer ( &clcache, file->db, consumerRID, consumerRuv, supplierRuv ); if ( rc != 0 ) goto done; @@ -5085,23 +5089,28 @@ static int _cl5PositionCursorForReplay (ReplicaId consumerRID, const RUV *consum if ((RUV_SUCCESS == ruv_get_min_csn(supplierRuv, &startCSN)) && startCSN) { /* must now free startCSN */ - csn_as_string(startCSN, PR_FALSE, csnStr); - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, - "%s: CSN %s not found and no purging, probably a reinit\n", - agmt_name, csnStr); - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, - "%s: Will try to use supplier min CSN %s to load changelog\n", - agmt_name, csnStr); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + csn_as_string(startCSN, PR_FALSE, csnStr); + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, + "%s: CSN %s not found and no purging, probably a reinit\n", + agmt_name, csnStr); + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, + "%s: Will try to use supplier min CSN %s to load changelog\n", + agmt_name, csnStr); + } rc = clcache_load_buffer (clcache, startCSN, DB_SET); } else { - slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, - "%s: CSN %s not found and no purging, probably a reinit\n", - agmt_name, csnStr); - slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, - "%s: Could not get the min csn from the supplier RUV\n", - agmt_name); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + csn_as_string(startCSN, PR_FALSE, csnStr); + slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, + "%s: CSN %s not found and no purging, probably a reinit\n", + agmt_name, csnStr); + slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, + "%s: Could not get the min csn from the supplier RUV\n", + agmt_name); + } rc = CL5_RUV_ERROR; goto done; } @@ -5110,8 +5119,11 @@ static int _cl5PositionCursorForReplay (ReplicaId consumerRID, const RUV *consum if (rc == 0) { haveChanges = PR_TRUE; rc = CL5_SUCCESS; - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, - "%s: CSN %s found, position set for replay\n", agmt_name, csnStr); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + csn_as_string(startCSN, PR_FALSE, csnStr); + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, + "%s: CSN %s found, position set for replay\n", agmt_name, csnStr); + } if (startCSN != csns[i]) { csn_free(&startCSN); } @@ -5121,33 +5133,44 @@ static int _cl5PositionCursorForReplay (ReplicaId consumerRID, const RUV *consum { /* check whether this csn should be present */ rc = _cl5CheckMissingCSN (startCSN, supplierRuv, file); + if (rc == CL5_MISSING_DATA) /* we should have had the change but we don't */ + { + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + csn_as_string(startCSN, PR_FALSE, csnStr); + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, + "%s: CSN %s not found, seems to be missing\n", agmt_name, csnStr); + } + } + else /* we are not as up to date or we purged */ + { + csn_as_string(startCSN, PR_FALSE, csnStr); + slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, + "%s: CSN %s not found, we aren't as up to date, or we purged\n", + agmt_name, csnStr); + } if (startCSN != csns[i]) { csn_free(&startCSN); } if (rc == CL5_MISSING_DATA) /* we should have had the change but we don't */ { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, - "%s: CSN %s not found, seems to be missing\n", agmt_name, csnStr); break; } else /* we are not as up to date or we purged */ { - slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, - "%s: CSN %s not found, we aren't as up to date, or we purged\n", - agmt_name, csnStr); continue; } } else { - if (startCSN != csns[i]) { - csn_free(&startCSN); - } - + csn_as_string(startCSN, PR_FALSE, csnStr); /* db error */ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, "%s: Failed to retrieve change with CSN %s; db error - %d %s\n", agmt_name, csnStr, rc, db_strerror(rc)); + if (startCSN != csns[i]) { + csn_free(&startCSN); + } + rc = CL5_DB_ERROR; break; } @@ -5369,9 +5392,11 @@ static int _cl5CheckMissingCSN (const CSN *csn, const RUV *supplierRuv, CL5DBFil { /* we have not seen any changes from this replica so it is ok not to have this csn */ - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: " - "can't locate %s csn: we have not seen any changes for replica %d\n", - csn_as_string (csn, PR_FALSE, csnStr), rid); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: " + "can't locate %s csn: we have not seen any changes for replica %d\n", + csn_as_string (csn, PR_FALSE, csnStr), rid); + } return CL5_SUCCESS; } @@ -5381,18 +5406,22 @@ static int _cl5CheckMissingCSN (const CSN *csn, const RUV *supplierRuv, CL5DBFil /* changelog never contained any changes for this replica */ if (csn_compare (csn, supplierCsn) <= 0) { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: " - "the change with %s csn was never logged because it was imported " - "during replica initialization\n", csn_as_string (csn, PR_FALSE, csnStr)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: " + "the change with %s csn was never logged because it was imported " + "during replica initialization\n", csn_as_string (csn, PR_FALSE, csnStr)); + } rc = CL5_PURGED_DATA; /* XXXggood is that the correct return value? */ } else { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: " - "change with %s csn has not yet been seen by this server; " - " last csn seen from that replica is %s\n", - csn_as_string (csn, PR_FALSE, csnStr), - csn_as_string (supplierCsn, PR_FALSE, csnStr)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: " + "change with %s csn has not yet been seen by this server; " + " last csn seen from that replica is %s\n", + csn_as_string (csn, PR_FALSE, csnStr), + csn_as_string (supplierCsn, PR_FALSE, csnStr)); + } rc = CL5_SUCCESS; } } @@ -5406,20 +5435,24 @@ static int _cl5CheckMissingCSN (const CSN *csn, const RUV *supplierRuv, CL5DBFil { if (csn_compare (csn, supplierCsn) <= 0) /* we should have the data but we don't */ { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: " - "change with %s csn has been purged by this server; " - "the current purge point for that replica is %s\n", - csn_as_string (csn, PR_FALSE, csnStr), - csn_as_string (purgeCsn, PR_FALSE, csnStr)); - rc = CL5_MISSING_DATA; + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: " + "change with %s csn has been purged by this server; " + "the current purge point for that replica is %s\n", + csn_as_string (csn, PR_FALSE, csnStr), + csn_as_string (purgeCsn, PR_FALSE, csnStr)); + } + rc = CL5_MISSING_DATA; } else { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: " - "change with %s csn has not yet been seen by this server; " - " last csn seen from that replica is %s\n", - csn_as_string (csn, PR_FALSE, csnStr), - csn_as_string (supplierCsn, PR_FALSE, csnStr)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5CheckMissingCSN: " + "change with %s csn has not yet been seen by this server; " + " last csn seen from that replica is %s\n", + csn_as_string (csn, PR_FALSE, csnStr), + csn_as_string (supplierCsn, PR_FALSE, csnStr)); + } rc = CL5_SUCCESS; } } @@ -6065,8 +6098,10 @@ static int _cl5ExportFile (PRFileDesc *prFile, Object *obj) file = (CL5DBFile*)object_get_data (obj); PR_ASSERT (file); - ruv_dump (file->purgeRUV, "clpurgeruv", prFile); - ruv_dump (file->maxRUV, "clmaxruv", prFile); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + ruv_dump (file->purgeRUV, "clpurgeruv", prFile); + ruv_dump (file->maxRUV, "clmaxruv", prFile); + } slapi_write_buffer (prFile, "\n", strlen("\n")); entry.op = &op; diff --git a/ldap/servers/plugins/replication/csnpl.c b/ldap/servers/plugins/replication/csnpl.c index 70bc853..62f4fc4 100644 --- a/ldap/servers/plugins/replication/csnpl.c +++ b/ldap/servers/plugins/replication/csnpl.c @@ -172,8 +172,10 @@ int csnplInsert (CSNPL *csnpl, const CSN *csn) if (rc != 0) { char s[CSN_STRSIZE]; - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, - "csnplInsert: failed to insert csn (%s) into pending list\n", csn_as_string(csn,PR_FALSE,s)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, + "csnplInsert: failed to insert csn (%s) into pending list\n", csn_as_string(csn,PR_FALSE,s)); + } return -1; } diff --git a/ldap/servers/plugins/replication/repl5_inc_protocol.c b/ldap/servers/plugins/replication/repl5_inc_protocol.c index 274a069..c9ad6fc 100644 --- a/ldap/servers/plugins/replication/repl5_inc_protocol.c +++ b/ldap/servers/plugins/replication/repl5_inc_protocol.c @@ -57,6 +57,7 @@ Stuff to do: Perhaps these events should be properties of the main protocol. */ +#include <plstr.h> #include "repl.h" #include "repl5.h" @@ -80,12 +81,16 @@ typedef struct repl5_inc_private /* Structures used to communicate with the result reading thread */ +#ifndef UIDSTR_SIZE +#define UIDSTR_SIZE 35 /* size of the string representation of the id */ +#endif + typedef struct repl5_inc_operation { int ldap_message_id; unsigned long operation_type; - char *csn_str; - char *uniqueid; + char csn_str[CSN_STRSIZE]; + char uniqueid[UIDSTR_SIZE+1]; ReplicaId replica_id; struct repl5_inc_operation *next; } repl5_inc_operation; @@ -214,15 +219,6 @@ static repl5_inc_operation *repl5_inc_pop_operation(result_data *rd) static void repl5_inc_op_free(repl5_inc_operation *op) { - /* First free any payload */ - if (op->csn_str) - { - slapi_ch_free((void **)&(op->csn_str)); - } - if (op->uniqueid) - { - slapi_ch_free((void **)&(op->uniqueid)); - } slapi_ch_free((void**)&op); } @@ -1389,8 +1385,6 @@ replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op, int *m LDAPMod **modrdn_mods = NULL; char csn_str[CSN_STRSIZE]; /* For logging only */ - csn_as_string(op->csn, PR_FALSE, csn_str); - /* Construct the replication info control that accompanies the operation */ if (SLAPI_OPERATION_ADD == op->operation_type) { @@ -1416,14 +1410,17 @@ replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op, int *m slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "%s: replay_update: Unable to create NSDS50ReplUpdateInfoControl " "for operation with csn %s. Skipping update.\n", - agmt_get_long_name(prp->agmt), csn_str); + agmt_get_long_name(prp->agmt), csn_as_string(op->csn, PR_FALSE, csn_str)); } else { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, - "%s: replay_update: Sending %s operation (dn=\"%s\" csn=%s)\n", - agmt_get_long_name(prp->agmt), - op2string(op->operation_type), REPL_GET_DN(&op->target_address), csn_str); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, + "%s: replay_update: Sending %s operation (dn=\"%s\" csn=%s)\n", + agmt_get_long_name(prp->agmt), + op2string(op->operation_type), REPL_GET_DN(&op->target_address), + csn_as_string(op->csn, PR_FALSE, csn_str)); + } /* What type of operation is it? */ switch (op->operation_type) { @@ -1486,15 +1483,19 @@ replay_update(Private_Repl_Protocol *prp, slapi_operation_parameters *op, int *m if (CONN_OPERATION_SUCCESS == return_value) { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, - "%s: replay_update: Consumer successfully sent operation with csn %s\n", - agmt_get_long_name(prp->agmt), csn_str); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, + "%s: replay_update: Consumer successfully sent operation with csn %s\n", + agmt_get_long_name(prp->agmt), csn_as_string(op->csn, PR_FALSE, csn_str)); + } } else { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, - "%s: replay_update: Consumer could not replay operation with csn %s\n", - agmt_get_long_name(prp->agmt), csn_str); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, + "%s: replay_update: Consumer could not replay operation with csn %s\n", + agmt_get_long_name(prp->agmt), csn_as_string(op->csn, PR_FALSE, csn_str)); + } } return return_value; } @@ -1884,11 +1885,11 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu /* Queue the details for pickup later in the response thread */ repl5_inc_operation *sop = NULL; sop = repl5_inc_operation_new(); - sop->csn_str = slapi_ch_strdup(csn_str); + PL_strncpyz(sop->csn_str, csn_str, sizeof(sop->csn_str)); sop->ldap_message_id = message_id; sop->operation_type = entry.op->operation_type; sop->replica_id = replica_id; - sop->uniqueid = slapi_ch_strdup(uniqueid); + PL_strncpyz(sop->uniqueid, uniqueid, sizeof(sop->uniqueid)); repl5_int_push_operation(rd,sop); } } diff --git a/ldap/servers/plugins/replication/repl5_plugins.c b/ldap/servers/plugins/replication/repl5_plugins.c index a0d45fb..c806c08 100644 --- a/ldap/servers/plugins/replication/repl5_plugins.c +++ b/ldap/servers/plugins/replication/repl5_plugins.c @@ -674,13 +674,15 @@ purge_entry_state_information (Slapi_PBlock *pb) } if (NULL != e) { - char csn_str[CSN_STRSIZE]; entry_purge_state_information(e, purge_csn); /* conntion is always null */ - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, - "Purged state information from entry %s up to " - "CSN %s\n", slapi_entry_get_dn(e), - csn_as_string(purge_csn, PR_FALSE, csn_str)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + char csn_str[CSN_STRSIZE]; + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, + "Purged state information from entry %s up to " + "CSN %s\n", slapi_entry_get_dn(e), + csn_as_string(purge_csn, PR_FALSE, csn_str)); + } } csn_free(&purge_csn); } diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c index acb7d1f..295ea72 100644 --- a/ldap/servers/plugins/replication/repl5_replica.c +++ b/ldap/servers/plugins/replication/repl5_replica.c @@ -2542,21 +2542,25 @@ int process_reap_entry (Slapi_Entry *entry, void *cb_data) if ((NULL == deletion_csn || csn_compare(deletion_csn, purge_csn) < 0) && (!is_ruv_tombstone_entry(entry))) { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, - "_replica_reap_tombstones: removing tombstone %s " - "because its deletion csn (%s) is less than the " - "purge csn (%s).\n", - escape_string(slapi_entry_get_dn(entry), ebuf), - csn_as_string(deletion_csn, PR_FALSE, deletion_csn_str), - csn_as_string(purge_csn, PR_FALSE, purge_csn_str)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, + "_replica_reap_tombstones: removing tombstone %s " + "because its deletion csn (%s) is less than the " + "purge csn (%s).\n", + escape_string(slapi_entry_get_dn(entry), ebuf), + csn_as_string(deletion_csn, PR_FALSE, deletion_csn_str), + csn_as_string(purge_csn, PR_FALSE, purge_csn_str)); + } _delete_tombstone(slapi_entry_get_dn(entry), slapi_entry_get_uniqueid(entry), 0); (*num_purged_entriesp)++; } else { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, - "_replica_reap_tombstones: NOT removing tombstone " - "%s\n", escape_string(slapi_entry_get_dn(entry),ebuf)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, + "_replica_reap_tombstones: NOT removing tombstone " + "%s\n", escape_string(slapi_entry_get_dn(entry),ebuf)); + } } (*num_entriesp)++; @@ -2939,10 +2943,12 @@ assign_csn_callback(const CSN *csn, void *data) char ebuf[BUFSIZ]; char csn_str[CSN_STRSIZE]; /* For logging only */ /* Ack, we can't keep track of min csn. Punt. */ - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "assign_csn_callback: " - "failed to insert csn %s for replica %s\n", - csn_as_string(csn, PR_FALSE, csn_str), - escape_string(slapi_sdn_get_dn(r->repl_root), ebuf)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "assign_csn_callback: " + "failed to insert csn %s for replica %s\n", + csn_as_string(csn, PR_FALSE, csn_str), + escape_string(slapi_sdn_get_dn(r->repl_root), ebuf)); + } csnplFree(&r->min_csn_pl); } } diff --git a/ldap/servers/plugins/replication/repl5_ruv.c b/ldap/servers/plugins/replication/repl5_ruv.c index 2e4af87..e5ddb39 100644 --- a/ldap/servers/plugins/replication/repl5_ruv.c +++ b/ldap/servers/plugins/replication/repl5_ruv.c @@ -1343,6 +1343,9 @@ ruv_dump(const RUV *ruv, char *ruv_name, PRFileDesc *prFile) int len = sizeof (buff); PR_ASSERT(NULL != ruv); + if (!slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + return; + } slapi_rwlock_rdlock (ruv->lock); @@ -1406,8 +1409,10 @@ int ruv_add_csn_inprogress (RUV *ruv, const CSN *csn) replica = ruvAddReplicaNoCSN (ruv, csn_get_replicaid (csn), NULL/*purl*/); if (replica == NULL) { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: failed to add replica" - " that created csn %s\n", csn_as_string (csn, PR_FALSE, csn_str)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: failed to add replica" + " that created csn %s\n", csn_as_string (csn, PR_FALSE, csn_str)); + } rc = RUV_MEMORY_ERROR; goto done; } @@ -1416,9 +1421,11 @@ int ruv_add_csn_inprogress (RUV *ruv, const CSN *csn) /* check first that this csn is not already covered by this RUV */ if (ruv_covers_csn_internal(ruv, csn, PR_FALSE)) { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: " - "the csn %s has already be seen - ignoring\n", - csn_as_string (csn, PR_FALSE, csn_str)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: " + "the csn %s has already be seen - ignoring\n", + csn_as_string (csn, PR_FALSE, csn_str)); + } rc = RUV_COVERS_CSN; goto done; } @@ -1426,21 +1433,27 @@ int ruv_add_csn_inprogress (RUV *ruv, const CSN *csn) rc = csnplInsert (replica->csnpl, csn); if (rc == 1) /* we already seen this csn */ { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: " - "the csn %s has already be seen - ignoring\n", - csn_as_string (csn, PR_FALSE, csn_str)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: " + "the csn %s has already be seen - ignoring\n", + csn_as_string (csn, PR_FALSE, csn_str)); + } rc = RUV_COVERS_CSN; } else if(rc != 0) { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: failed to insert csn %s" + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: failed to insert csn %s" " into pending list\n", csn_as_string (csn, PR_FALSE, csn_str)); + } rc = RUV_UNKNOWN_ERROR; } else { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: successfully inserted csn %s" - " into pending list\n", csn_as_string (csn, PR_FALSE, csn_str)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: successfully inserted csn %s" + " into pending list\n", csn_as_string (csn, PR_FALSE, csn_str)); + } rc = RUV_SUCCESS; } @@ -1508,8 +1521,10 @@ int ruv_update_ruv (RUV *ruv, const CSN *csn, const char *replica_purl, PRBool i } else { - slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_update_ruv: " - "successfully committed csn %s\n", csn_as_string(csn, PR_FALSE, csn_str)); + if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { + slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_update_ruv: " + "successfully committed csn %s\n", csn_as_string(csn, PR_FALSE, csn_str)); + } } if ((max_csn = csnplRollUp(replica->csnpl, &first_csn)) != NULL) -- 1.7.1
-- 389-devel mailing list 389-devel@xxxxxxxxxxxxxxxxxxxxxxx https://admin.fedoraproject.org/mailman/listinfo/389-devel