From 39f0d79485fc3217155d82edc2bc3bc9d2ce2573 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 21 Nov 2009 21:02:49 +0000 Subject: [PATCH] use macros for fake connid --- servers/slapd/backend.c | 2 +- servers/slapd/slap.h | 5 +++++ servers/slapd/syncrepl.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index b003354219..1032008353 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -762,7 +762,7 @@ be_shadow_update( Operation *op ) /* This assumes that all internal ops (connid <= -1000) on a syncrepl * database are syncrepl operations. */ - return (( SLAP_SYNC_SHADOW( op->o_bd ) && op->o_connid <= -1000 ) || + return ( ( SLAP_SYNC_SHADOW( op->o_bd ) && SLAPD_SYNC_IS_SYNCCONN( op->o_connid ) ) || ( SLAP_SHADOW( op->o_bd ) && be_isupdate_dn( op->o_bd, &op->o_ndn ) ) ); } diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 6015dbf837..bc31eea45e 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1701,6 +1701,11 @@ typedef BackendDB Backend; struct syncinfo_s; +/* fake conn connid constructed as SLAPD_SYNC_CONN_OFFSET - rid */ +#define SLAPD_SYNC_SYNCCONN_OFFSET (-1000) +#define SLAPD_SYNC_IS_SYNCCONN(connid) ((connid) <= SLAPD_SYNC_SYNCCONN_OFFSET) +#define SLAPD_SYNC_RID2SYNCCONN(rid) (SLAPD_SYNC_SYNCCONN_OFFSET - (rid)) + #define SLAP_SYNC_RID_MAX 999 #define SLAP_SYNC_SID_MAX 4095 /* based on liblutil/csn.c field width */ #define SLAP_SYNCUUID_SET_SIZE 256 diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 414ab32506..a9b3d7150b 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -1354,7 +1354,7 @@ do_syncrepl( connection_fake_init( &conn, &opbuf, ctx ); op = &opbuf.ob_op; /* o_connids must be unique for slap_graduate_commit_csn */ - op->o_connid = -1000 - si->si_rid; + op->o_connid = SLAPD_SYNC_RID2SYNCCONN(si->si_rid); op->o_managedsait = SLAP_CONTROL_NONCRITICAL; be = si->si_be; -- 2.39.5