From c0c24cfec5baf904b9e8f3b8192e15015390c37a Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 10 Apr 2004 10:00:58 +0000 Subject: [PATCH] first round of SHADOW flags/isupdate test unification --- servers/slapd/back-bdb/add.c | 2 +- servers/slapd/back-bdb/delete.c | 2 +- servers/slapd/back-bdb/modrdn.c | 2 +- servers/slapd/back-ldap/add.c | 2 +- servers/slapd/back-ldap/modify.c | 2 +- servers/slapd/back-ldbm/add.c | 2 +- servers/slapd/back-ldbm/delete.c | 2 +- servers/slapd/back-ldbm/modrdn.c | 4 ++-- servers/slapd/backend.c | 20 ++++++++++++++++++-- servers/slapd/overlays/rwm.c | 2 +- servers/slapd/proto-slap.h | 5 ++++- servers/slapd/slap.h | 6 ++++-- 12 files changed, 36 insertions(+), 15 deletions(-) diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 3901900011..476043febe 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -298,7 +298,7 @@ retry: /* transaction retry */ * no parent! * if not attempting to add entry at suffix or with parent "" */ - if ((( !be_isroot( op ) && !be_isupdate(op) && !syncrepl_isupdate(op)) + if ((( !be_isroot( op ) && !be_shadow_update(op) ) || pdn.bv_len > 0 ) && !is_entry_glue( op->oq_add.rs_e )) { #ifdef NEW_LOGGING diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index feb7b81e9c..84758b89f8 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -246,7 +246,7 @@ retry: /* transaction retry */ /* no parent, must be root to delete */ if( ! be_isroot( op ) ) { if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) - || be_isupdate( op ) || syncrepl_isupdate( op ) ) { + || be_shadow_update( op ) ) { p = (Entry *)&slap_entry_root; /* check parent for "children" acl */ diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 9e3529be7f..ed817dedb8 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -396,7 +396,7 @@ retry: /* transaction retry */ isroot = be_isroot( op ); if ( ! isroot ) { if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) - || be_isupdate( op ) || syncrepl_isupdate( op ) ) { + || be_shadow_update( op ) ) { p = (Entry *)&slap_entry_root; diff --git a/servers/slapd/back-ldap/add.c b/servers/slapd/back-ldap/add.c index 803bc4aef9..837f4d3a3a 100644 --- a/servers/slapd/back-ldap/add.c +++ b/servers/slapd/back-ldap/add.c @@ -90,7 +90,7 @@ ldap_back_add( dc.ctx = "addAttrDN"; #endif - isupdate = be_isupdate( op ) || syncrepl_isupdate( op ); + isupdate = be_shadow_update( op ); for (i=0, a=op->oq_add.rs_e->e_attrs; a; a=a->a_next) { if ( !isupdate && a->a_desc->ad_type->sat_no_user_mod ) { continue; diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c index c0670caf6a..95247cbeef 100644 --- a/servers/slapd/back-ldap/modify.c +++ b/servers/slapd/back-ldap/modify.c @@ -91,7 +91,7 @@ ldap_back_modify( dc.ctx = "modifyAttrDN"; #endif - isupdate = be_isupdate( op ) || syncrepl_isupdate( op ); + isupdate = be_shadow_update( op ); for (i=0, ml=op->oq_modify.rs_modlist; ml; ml=ml->sml_next) { int is_oc = 0; diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index d415b2ec09..e1dfbbbb8f 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -247,7 +247,7 @@ ldbm_back_add( } else { assert( pdn.bv_val == NULL || *pdn.bv_val == '\0' ); - if (( !be_isroot(op) && !be_isupdate(op) && !syncrepl_isupdate(op)) + if (( !be_isroot(op) && !be_shadow_update(op) ) && !is_entry_glue( op->oq_add.rs_e )) { ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock); diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index 24b9ac36b3..234b30a3ab 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -196,7 +196,7 @@ ldbm_back_delete( /* no parent, must be root to delete */ if( ! be_isroot( op ) ) { if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) - || be_isupdate( op ) || syncrepl_isupdate( op ) ) { + || be_shadow_update( op ) ) { p = (Entry *)&slap_entry_root; rc = access_allowed( op, p, diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index acab4030da..ccc7bf9233 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -249,7 +249,7 @@ ldbm_back_modrdn( isroot = be_isroot( op ); if ( ! isroot ) { if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) - || be_isupdate( op ) || syncrepl_isupdate( op ) ) { + || be_shadow_update( op ) ) { int can_access; p = (Entry *)&slap_entry_root; @@ -424,7 +424,7 @@ ldbm_back_modrdn( if ( ! isroot ) { if ( be_issuffix( op->o_bd, (struct berval *)&slap_empty_bv ) - || be_isupdate( op ) || syncrepl_isupdate( op )) { + || be_shadow_update( op ) ) { int can_access; np = (Entry *)&slap_entry_root; diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index db30adeb80..b8f4b17d00 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -728,9 +728,25 @@ be_isroot_dn( Backend *be, struct berval *ndn ) } int -be_isupdate( Operation *op ) +be_sync_update( Operation *op ) { - return ( be_isupdate_dn( op->o_bd, &op->o_ndn )); + return ( SLAP_SYNC_SHADOW( op->o_bd ) && syncrepl_isupdate( op ) ); +} + +int +be_slurp_update( Operation *op ) +{ + return ( SLAP_SLURP_SHADOW( op->o_bd ) && be_isupdate_dn( op->o_bd, &op->o_ndn )); +} + +int +be_shadow_update( Operation *op ) +{ +#if 0 + return ( be_sync_update( op ) || be_slurp_update( op ) ); +#endif + /* NOTE: this is slightly more efficient */ + return ( SLAP_SHADOW( op->o_bd ) && ( syncrepl_isupdate( op ) || be_isupdate_dn( op->o_bd, &op->o_ndn ) ) ); } int diff --git a/servers/slapd/overlays/rwm.c b/servers/slapd/overlays/rwm.c index 9443ad27e0..5962963381 100644 --- a/servers/slapd/overlays/rwm.c +++ b/servers/slapd/overlays/rwm.c @@ -100,7 +100,7 @@ rwm_add( Operation *op, SlapReply *rs ) } /* Count number of attributes in entry */ - isupdate = be_isupdate( op ) || syncrepl_isupdate( op ); + isupdate = be_shadow_update( op ); for ( i = 0, ap = &op->oq_add.rs_e->e_attrs; *ap; ) { struct berval mapped; Attribute *a; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 655d26cbcf..0400c5282a 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -225,7 +225,10 @@ LDAP_SLAPD_F (int) be_issuffix LDAP_P(( Backend *be, LDAP_SLAPD_F (int) be_isroot LDAP_P(( Operation *op )); LDAP_SLAPD_F (int) be_isroot_dn LDAP_P(( Backend *be, struct berval *ndn )); LDAP_SLAPD_F (int) be_isroot_pw LDAP_P(( Operation *op )); -LDAP_SLAPD_F (int) be_isupdate LDAP_P(( Operation *op )); +LDAP_SLAPD_F (int) be_sync_update LDAP_P(( Operation *op )); +LDAP_SLAPD_F (int) be_slurp_update LDAP_P(( Operation *op )); +#define be_isupdate( op ) be_slurp_update( (op) ) +LDAP_SLAPD_F (int) be_shadow_update LDAP_P(( Operation *op )); LDAP_SLAPD_F (int) be_isupdate_dn LDAP_P(( Backend *be, struct berval *ndn )); LDAP_SLAPD_F (struct berval *) be_root_dn LDAP_P(( Backend *be )); LDAP_SLAPD_F (int) be_entry_get_rw LDAP_P(( struct slap_op *o, diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index ae03413eb7..bd4f74b92a 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1450,9 +1450,9 @@ struct slap_backend_db { #define SLAP_DBFLAG_NOLASTMOD 0x0001U #define SLAP_DBFLAG_NO_SCHEMA_CHECK 0x0002U #define SLAP_DBFLAG_GLUE_INSTANCE 0x0010U /* a glue backend */ -#define SLAP_DBFLAG_GLUE_SUBORDINATE 0x0020U /* child of a glue hierarchy */ +#define SLAP_DBFLAG_GLUE_SUBORDINATE 0x0020U /* child of a glue hierarchy */ #define SLAP_DBFLAG_GLUE_LINKED 0x0040U /* child is connected to parent */ -#define SLAP_DBFLAG_SHADOW 0x8000U /* a shadow */ +#define SLAP_DBFLAG_SHADOW 0x8000U /* a shadow */ #define SLAP_DBFLAG_SYNC_SHADOW 0x1000U /* a sync shadow */ #define SLAP_DBFLAG_SLURP_SHADOW 0x2000U /* a slurp shadow */ slap_mask_t be_flags; @@ -1468,6 +1468,8 @@ struct slap_backend_db { #define SLAP_GLUE_LINKED(be) \ (SLAP_DBFLAGS(be) & SLAP_DBFLAG_GLUE_LINKED) #define SLAP_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SHADOW) +#define SLAP_SYNC_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SYNC_SHADOW) +#define SLAP_SLURP_SHADOW(be) (SLAP_DBFLAGS(be) & SLAP_DBFLAG_SLURP_SHADOW) slap_mask_t be_restrictops; /* restriction operations */ #define SLAP_RESTRICT_OP_ADD 0x0001U -- 2.39.5