Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/replication
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv11144/ldap/servers/plugins/replication
Modified Files:
repl.h repl5.h repl5_init.c repl5_replica.c repl5_total.c
repl_connext.c repl_extop.c replutil.c
Log Message:
Related: 207457
Summary: Add support for 64-bit counters (phase 1).
Index: repl.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- repl.h 10 Nov 2006 23:45:17 -0000 1.7
+++ repl.h 17 Oct 2008 22:12:47 -0000 1.8
@@ -44,6 +44,22 @@
#ifndef _REPL_H_
#define _REPL_H_
+/* Required to get portable printf/scanf format macros */
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+
+/* NSPR uses the print macros a bit differently than ANSI C. We
+ * need to use ll for a 64-bit integer, even when a long is 64-bit.
+ */
+#undef PRIu64
+#define PRIu64 "llu"
+#undef PRI64
+#define PRI64 "ll"
+
+#else
+#error Need to define portable format macros such as PRIu64
+#endif /* HAVE_INTTYPES_H */
+
#include <limits.h>
#include <time.h>
#include <stdio.h>
Index: repl5.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- repl5.h 24 Jun 2008 22:22:09 -0000 1.11
+++ repl5.h 17 Oct 2008 22:12:47 -0000 1.12
@@ -443,10 +443,10 @@
during addition of the replica over LDAP */
Replica *replica_new_from_entry (Slapi_Entry *e, char *errortext, PRBool is_add_operation);
void replica_destroy(void **arg);
-PRBool replica_get_exclusive_access(Replica *r, PRBool *isInc, int connid, int opid,
+PRBool replica_get_exclusive_access(Replica *r, PRBool *isInc, PRUint64 connid, int opid,
const char *locking_purl,
char **current_purl);
-void replica_relinquish_exclusive_access(Replica *r, int connid, int opid);
+void replica_relinquish_exclusive_access(Replica *r, PRUint64 connid, int opid);
PRBool replica_get_tombstone_reap_active(const Replica *r);
const Slapi_DN *replica_get_root(const Replica *r);
const char *replica_get_name(const Replica *r);
Index: repl5_init.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_init.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- repl5_init.c 10 Nov 2006 23:45:17 -0000 1.7
+++ repl5_init.c 17 Oct 2008 22:12:47 -0000 1.8
@@ -178,7 +178,8 @@
char*
get_repl_session_id (Slapi_PBlock *pb, char *idstr, CSN **csn)
{
- int connid=-1, opid=-1;
+ int opid=-1;
+ PRUint64 connid = 0;
CSN *opcsn;
char opcsnstr[CSN_STRSIZE];
@@ -192,7 +193,7 @@
/* Avoid "Connection is NULL and hence cannot access SLAPI_CONN_ID" */
if (opid) {
slapi_pblock_get (pb, SLAPI_CONN_ID, &connid);
- PR_snprintf (idstr, REPL_SESSION_ID_SIZE, "conn=%d op=%d", connid, opid);
+ PR_snprintf (idstr, REPL_SESSION_ID_SIZE, "conn=%" PRIu64 " op=%d", connid, opid);
}
slapi_pblock_get ( pb, SLAPI_OPERATION, &op );
Index: repl5_replica.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_replica.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- repl5_replica.c 8 Oct 2008 17:29:03 -0000 1.18
+++ repl5_replica.c 17 Oct 2008 22:12:47 -0000 1.19
@@ -405,7 +405,7 @@
* current_purl is the supplier who already has access, if any
*/
PRBool
-replica_get_exclusive_access(Replica *r, PRBool *isInc, int connid, int opid,
+replica_get_exclusive_access(Replica *r, PRBool *isInc, PRUint64 connid, int opid,
const char *locking_purl,
char **current_purl)
{
@@ -421,7 +421,7 @@
*isInc = (r->repl_state_flags & REPLICA_INCREMENTAL_IN_PROGRESS);
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "conn=%d op=%d repl=\"%s\": "
+ "conn=%" PRIu64 " op=%d repl=\"%s\": "
"Replica in use locking_purl=%s\n",
connid, opid,
escape_string(slapi_sdn_get_dn(r->repl_root),ebuf),
@@ -435,7 +435,7 @@
else
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "conn=%d op=%d repl=\"%s\": Acquired replica\n",
+ "conn=%" PRIu64 " op=%d repl=\"%s\": Acquired replica\n",
connid, opid,
escape_string(slapi_sdn_get_dn(r->repl_root),ebuf));
r->repl_state_flags |= REPLICA_IN_USE;
@@ -463,7 +463,7 @@
* Relinquish exclusive access to the replica
*/
void
-replica_relinquish_exclusive_access(Replica *r, int connid, int opid)
+replica_relinquish_exclusive_access(Replica *r, PRUint64 connid, int opid)
{
char ebuf[BUFSIZ];
PRBool isInc;
@@ -476,13 +476,13 @@
if (!(r->repl_state_flags & REPLICA_IN_USE))
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "conn=%d op=%d repl=\"%s\": "
+ "conn=%" PRIu64 " op=%d repl=\"%s\": "
"Replica not in use\n",
connid, opid,
escape_string(slapi_sdn_get_dn(r->repl_root),ebuf));
} else {
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "conn=%d op=%d repl=\"%s\": "
+ "conn=%" PRIu64 " op=%d repl=\"%s\": "
"Released replica\n",
connid, opid,
escape_string(slapi_sdn_get_dn(r->repl_root),ebuf));
Index: repl5_total.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_total.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- repl5_total.c 25 Jan 2008 00:59:00 -0000 1.11
+++ repl5_total.c 17 Oct 2008 22:12:47 -0000 1.12
@@ -76,6 +76,7 @@
}
*/
+#include "repl.h"
#include "repl5.h"
#define CSN_TYPE_VALUE_UPDATED_ON_WIRE 1
@@ -848,11 +849,10 @@
int rc;
Slapi_Entry *e = NULL;
Slapi_Connection *conn = NULL;
- int connid, opid;
+ PRUint64 connid = 0;
+ int opid = 0;
- connid = 0;
slapi_pblock_get(pb, SLAPI_CONN_ID, &connid);
- opid = 0;
slapi_pblock_get(pb, SLAPI_OPERATION_ID, &opid);
/* Decode the extended operation */
@@ -881,7 +881,7 @@
const char *dn = slapi_entry_get_dn_const(e);
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
"Error %d: could not import entry dn %s "
- "for total update operation conn=%d op=%d\n",
+ "for total update operation conn=%" PRIu64 " op=%d\n",
rc, dn, connid, opid);
rc = -1;
}
@@ -891,7 +891,7 @@
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
"Error %d: could not decode the total update extop "
- "for total update operation conn=%d op=%d\n",
+ "for total update operation conn=%" PRIu64 " op=%d\n",
rc, connid, opid);
}
Index: repl_connext.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl_connext.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- repl_connext.c 10 Nov 2006 23:45:17 -0000 1.6
+++ repl_connext.c 17 Oct 2008 22:12:47 -0000 1.7
@@ -78,7 +78,7 @@
/* consumer connection extension destructor */
void consumer_connection_extension_destructor (void *ext, void *object, void *parent)
{
- int connid = 0;
+ PRUint64 connid = 0;
if (ext)
{
/* Check to see if this replication session has acquired
@@ -101,7 +101,7 @@
slapi_pblock_get(pb, SLAPI_CONN_ID, &connid);
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
"Aborting total update in progress for replicated "
- "area %s connid=%d\n", slapi_sdn_get_dn(repl_root_sdn),
+ "area %s connid=%" PRIu64 "\n", slapi_sdn_get_dn(repl_root_sdn),
connid);
slapi_stop_bulk_import(pb);
}
Index: repl_extop.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl_extop.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- repl_extop.c 24 Jun 2008 22:22:09 -0000 1.13
+++ repl_extop.c 17 Oct 2008 22:12:47 -0000 1.14
@@ -562,7 +562,8 @@
char *bind_dn = NULL;
Object *ruv_object = NULL;
RUV *supplier_ruv = NULL;
- int connid, opid;
+ PRUint64 connid = 0;
+ int opid = 0;
PRBool isInc = PR_FALSE; /* true if incremental update */
char *locking_purl = NULL; /* the supplier contacting us */
char *current_purl = NULL; /* the supplier which already has exclusive access */
@@ -581,9 +582,7 @@
goto send_response;
}
- connid = 0;
slapi_pblock_get(pb, SLAPI_CONN_ID, &connid);
- opid = 0;
slapi_pblock_get(pb, SLAPI_OPERATION_ID, &opid);
/*
@@ -606,7 +605,7 @@
/* Stash info that this is an incremental update session */
connext->repl_protocol_version = REPL_PROTOCOL_50_INCREMENTAL;
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "conn=%d op=%d repl=\"%s\": Begin incremental protocol\n",
+ "conn=%" PRIu64 " op=%d repl=\"%s\": Begin incremental protocol\n",
connid, opid, repl_root);
isInc = PR_TRUE;
}
@@ -618,7 +617,7 @@
connext->repl_protocol_version = REPL_PROTOCOL_50_TOTALUPDATE;
}
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "conn=%d op=%d repl=\"%s\": Begin total protocol\n",
+ "conn=%" PRIu64 " op=%d repl=\"%s\": Begin total protocol\n",
connid, opid, repl_root);
isInc = PR_FALSE;
}
@@ -627,7 +626,7 @@
/* Stash info that this is an incremental update session */
connext->repl_protocol_version = REPL_PROTOCOL_50_INCREMENTAL;
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "conn=%d op=%d repl=\"%s\": Begin 7.1 incremental protocol\n",
+ "conn=%" PRIu64 " op=%d repl=\"%s\": Begin 7.1 incremental protocol\n",
connid, opid, repl_root);
isInc = PR_TRUE;
}
@@ -639,7 +638,7 @@
connext->repl_protocol_version = REPL_PROTOCOL_71_TOTALUPDATE;
}
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "conn=%d op=%d repl=\"%s\": Begin 7.1 total protocol\n",
+ "conn=%" PRIu64 " op=%d repl=\"%s\": Begin 7.1 total protocol\n",
connid, opid, repl_root);
isInc = PR_FALSE;
}
@@ -661,7 +660,7 @@
if (replica_is_being_configured(repl_root))
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "conn=%d op=%d replica=\"%s\": "
+ "conn=%" PRIu64 " op=%d replica=\"%s\": "
"Replica is being configured: try again later\n",
connid, opid, repl_root);
response = NSDS50_REPL_REPLICA_BUSY;
@@ -714,7 +713,7 @@
{
response = NSDS50_REPL_EXCESSIVE_CLOCK_SKEW;
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
- "conn=%d op=%d repl=\"%s\": "
+ "conn=%" PRIu64 " op=%d repl=\"%s\": "
"Excessive clock skew from supplier RUV\n",
connid, opid, repl_root);
goto send_response;
@@ -750,7 +749,7 @@
if (check_replica_id_uniqueness(replica, supplier_ruv) != 0){
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "conn=%d op=%d repl=\"%s\": "
+ "conn=%" PRIu64 " op=%d repl=\"%s\": "
"Replica has same replicaID %d as supplier\n",
connid, opid, repl_root, replica_get_rid(replica));
response = NSDS50_REPL_REPLICAID_ERROR;
@@ -763,7 +762,7 @@
* the session's conn id and op id to identify the the supplier.
*/
/* junkrc = ruv_get_first_id_and_purl(supplier_ruv, &junkrid, &locking_purl); */
- PR_snprintf(locking_session, sizeof(locking_session), "conn=%d id=%d", connid, opid);
+ PR_snprintf(locking_session, sizeof(locking_session), "conn=%" PRIu64 " id=%d", connid, opid);
locking_purl = &locking_session[0];
if (replica_get_exclusive_access(replica, &isInc, connid, opid,
locking_purl,
@@ -877,7 +876,7 @@
}
slapi_log_error (resp_log_level, repl_plugin_name,
- "conn=%d op=%d replica=\"%s\": "
+ "conn=%" PRIu64 " op=%d replica=\"%s\": "
"Unable to acquire replica: error: %s%s\n",
connid, opid,
(replica ? slapi_sdn_get_dn(replica_get_root(replica)) : "unknown"),
@@ -901,7 +900,7 @@
slapi_pblock_set(pb, SLAPI_EXT_OP_RET_OID, REPL_NSDS50_REPLICATION_RESPONSE_OID);
slapi_pblock_set(pb, SLAPI_EXT_OP_RET_VALUE, resp_bval);
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name,
- "conn=%d op=%d repl=\"%s\": "
+ "conn=%" PRIu64 " op=%d repl=\"%s\": "
"StartNSDS50ReplicationRequest: response=%d rc=%d\n",
connid, opid, repl_root,
response, rc);
@@ -1008,7 +1007,8 @@
ber_int_t response;
void *conn;
consumer_connection_extension *connext = NULL;
- int connid=-1, opid=-1;
+ PRUint64 connid = 0;
+ int opid=-1;
/* Decode the extended operation */
if (decode_endrepl_extop(pb, &repl_root) == -1)
Index: replutil.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/replutil.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- replutil.c 15 Oct 2008 06:29:58 -0000 1.12
+++ replutil.c 17 Oct 2008 22:12:47 -0000 1.13
@@ -817,16 +817,17 @@
int repl_op = 0;
int local_backend = -1; /* index of local backend */
int chaining_backend = -1; /* index of chain backend */
+ int is_internal = 0;
PRBool local_online = PR_FALSE; /* true if the local db is online */
int ii;
int opid;
#ifdef DEBUG_CHAIN_ON_UPDATE
- int connid;
+ PRUint64 connid = 0;
#endif
slapi_pblock_get(pb, SLAPI_OPERATION, &op);
#ifdef DEBUG_CHAIN_ON_UPDATE
if (operation_is_flag_set(op, OP_FLAG_INTERNAL)) {
- connid=-1; /* -1: internal op in a log msg */
+ is_internal = 1;
} else {
slapi_pblock_get(pb, SLAPI_CONN_ID, &connid);
}
@@ -853,11 +854,18 @@
}
}
#ifdef DEBUG_CHAIN_ON_UPDATE
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=%d op=%d be "
- "%s is the %s backend and is %s\n",
- connid, opid,
- mtn_be_names[ii], (chaining_backend == ii) ? "chaining" : "local",
- (mtn_be_states[ii] == SLAPI_BE_STATE_ON) ? "online" : "offline");
+ if (is_internal) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=-1 op=%d be "
+ "%s is the %s backend and is %s\n", opid,
+ mtn_be_names[ii], (chaining_backend == ii) ? "chaining" : "local",
+ (mtn_be_states[ii] == SLAPI_BE_STATE_ON) ? "online" : "offline");
+ } else {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=%" PRIu64 " op=%d be "
+ "%s is the %s backend and is %s\n", connid, opid,
+ mtn_be_names[ii], (chaining_backend == ii) ? "chaining" : "local",
+ (mtn_be_states[ii] == SLAPI_BE_STATE_ON) ? "online" : "offline");
+
+ }
#endif
}
@@ -880,9 +888,13 @@
(op_type == SLAPI_OPERATION_UNBIND) ||
(op_type == SLAPI_OPERATION_COMPARE))) {
#ifdef DEBUG_CHAIN_ON_UPDATE
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=%d op=%d op is "
- "%d: using local backend\n",
- connid, opid, op_type);
+ if (is_internal) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=-1 op=%d op is "
+ "%d: using local backend\n", opid, op_type);
+ } else {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=%" PRIu64 " op=%d op is "
+ "%d: using local backend\n", connid, opid, op_type);
+ }
#endif
return local_backend;
}
@@ -899,8 +911,13 @@
slapi_pblock_get(pb, SLAPI_REQUESTOR_DN, &requestor_dn);
if (slapi_dn_isroot(requestor_dn)) {
#ifdef DEBUG_CHAIN_ON_UPDATE
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=%d op=%d requestor "
+ if (is_internal) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=-1 op=%d requestor "
+ "is root: using local backend\n", opid);
+ } else {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=%" PRIu64 " op=%d requestor "
"is root: using local backend\n", connid, opid);
+ }
#endif
return local_backend;
}
@@ -911,8 +928,13 @@
slapi_pblock_get(pb, SLAPI_IS_REPLICATED_OPERATION, &repl_op);
if (repl_op) {
#ifdef DEBUG_CHAIN_ON_UPDATE
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=%d op=%d op is "
+ if (is_internal) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=-1 op=%d op is "
+ "replicated: using local backend\n", opid);
+ } else {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=%" PRIu64 " op=%d op is "
"replicated: using local backend\n", connid, opid);
+ }
#endif
return local_backend;
}
@@ -923,8 +945,13 @@
extern int config_get_pw_is_global_policy();
if (!config_get_pw_is_global_policy()) {
#ifdef DEBUG_CHAIN_ON_UPDATE
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=%d op=%d using "
+ if (is_internal) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=-1 op=%d using "
+ "local backend for local password policy\n", opid);
+ } else {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=%" PRIu64 " op=%d using "
"local backend for local password policy\n", connid, opid);
+ }
#endif
return local_backend;
}
@@ -935,8 +962,13 @@
* use the chaining backend
*/
#ifdef DEBUG_CHAIN_ON_UPDATE
- slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=%d op=%d using "
+ if (is_internal) {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=-1 op=%d using "
+ "chaining backend\n", opid);
+ } else {
+ slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "repl_chain_on_update: conn=%" PRIu64 " op=%d using "
"chaining backend\n", connid, opid);
+ }
#endif
return chaining_backend;
}