From 55501e886f54d857db7a8e7b95e8a0310596188b Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Thu, 10 Jan 2002 22:34:11 +0000 Subject: [PATCH] Rework backend (lastmod + glue + system schema) flags --- servers/slapd/add.c | 4 +--- servers/slapd/backend.c | 10 ++++++---- servers/slapd/backglue.c | 24 ++++++++++++++---------- servers/slapd/config.c | 14 ++++++++------ servers/slapd/modify.c | 4 +--- servers/slapd/proto-slap.h | 1 - servers/slapd/root_dse.c | 3 ++- servers/slapd/slap.h | 22 +++++++++++++++------- servers/slapd/tools/slapcommon.c | 4 ++-- 9 files changed, 49 insertions(+), 37 deletions(-) diff --git a/servers/slapd/add.c b/servers/slapd/add.c index e167eb5b1a..426ff27b57 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -262,9 +262,7 @@ do_add( Connection *conn, Operation *op ) goto done; } - if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED && - global_lastmod == ON)) && !repl_user ) - { + if ( SLAP_LASTMOD(be) && !repl_user ) { for( modtail = &modlist; *modtail != NULL; modtail = &(*modtail)->sml_next ) diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 61bfb2ae04..3c5d842059 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -533,9 +533,11 @@ select_backend( for ( j = 0; backends[i].be_nsuffix != NULL && backends[i].be_nsuffix[j] != NULL; j++ ) { - if ((backends[i].be_glueflags&SLAP_GLUE_SUBORDINATE)&& - noSubs) + if (( backends[i].be_flags & SLAP_BFLAG_GLUE_SUBORDINATE ) + && noSubs ) + { continue; + } len = backends[i].be_nsuffix[j]->bv_len; @@ -997,7 +999,7 @@ backend_group( /* we won't attempt to send it to a different backend */ be = select_backend( gr_ndn, 0, - (be->be_glueflags & SLAP_GLUE_INSTANCE)); + (be->be_flags & SLAP_BFLAG_GLUE_INSTANCE)); if (be == NULL) { return LDAP_NO_SUCH_OBJECT; @@ -1058,7 +1060,7 @@ backend_attribute( /* we won't attempt to send it to a different backend */ be = select_backend( edn, 0, - (be->be_glueflags & SLAP_GLUE_INSTANCE)); + (be->be_flags & SLAP_BFLAG_GLUE_INSTANCE)); if (be == NULL) { return LDAP_NO_SUCH_OBJECT; diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index e7299d7511..f7f68ffeec 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -785,24 +785,27 @@ glue_sub_init( ) * backends and connect them to their superior. */ for (i = nBackendDB - 1, b1=&backendDB[i]; cont && i>=0; b1--,i--) { - if (b1->be_glueflags & SLAP_GLUE_SUBORDINATE) { + if (b1->be_flags & SLAP_BFLAG_GLUE_SUBORDINATE) { /* The last database cannot be a subordinate of noone */ - if (i == nBackendDB - 1) - b1->be_glueflags ^= SLAP_GLUE_SUBORDINATE; + if (i == nBackendDB - 1) { + b1->be_flags ^= SLAP_BFLAG_GLUE_SUBORDINATE; + } continue; } gi = NULL; for (j = i-1, be=&backendDB[j]; j>=0; be--,j--) { - if (!(be->be_glueflags & SLAP_GLUE_SUBORDINATE)) + if (!(be->be_flags & SLAP_BFLAG_GLUE_SUBORDINATE)) { continue; + } /* We will only link it once */ - if (be->be_glueflags & SLAP_GLUE_LINKED) + if (be->be_flags & SLAP_BFLAG_GLUE_LINKED) { continue; - if (!dnIsSuffix(be->be_nsuffix[0], - b1->be_nsuffix[0])) + } + if (!dnIsSuffix(be->be_nsuffix[0], b1->be_nsuffix[0])) { continue; + } cont--; - be->be_glueflags |= SLAP_GLUE_LINKED; + be->be_flags |= SLAP_BFLAG_GLUE_LINKED; if (gi == NULL) { /* We create a copy of the superior's be * structure, pointing to all of its original @@ -811,9 +814,10 @@ glue_sub_init( ) * is used whenever we have operations to pass * down to the real database. */ - b1->be_glueflags |= SLAP_GLUE_INSTANCE; + b1->be_flags |= SLAP_BFLAG_GLUE_INSTANCE; gi = (glueinfo *)ch_malloc(sizeof(glueinfo)); - gi->be = (BackendDB *)ch_malloc(sizeof(BackendDB) + sizeof(BackendInfo)); + gi->be = (BackendDB *)ch_malloc( + sizeof(BackendDB) + sizeof(BackendInfo)); bi = (BackendInfo *)(gi->be+1); *gi->be = *b1; gi->nodes = 0; diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 93a9934344..221ef9c22a 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -40,7 +40,6 @@ slap_mask_t global_disallows = 0; slap_mask_t global_requires = 0; slap_ssf_set_t global_ssf_set; char *replogfile; -int global_lastmod = ON; int global_idletimeout = 0; char *global_host = NULL; char *global_realm = NULL; @@ -78,6 +77,7 @@ read_config( const char *fname ) int rc; struct berval vals[2]; + static int lastmod = ON; static BackendInfo *bi = NULL; static BackendDB *be = NULL; @@ -204,6 +204,8 @@ read_config( const char *fname ) bi = NULL; be = backend_db_init( cargv[1] ); + if( lastmod ) be->be_flags |= SLAP_BFLAG_LASTMOD; + if( be == NULL ) { #ifdef NEW_LOGGING LDAP_LOG(( "config", LDAP_LEVEL_CRIT, @@ -842,7 +844,7 @@ read_config( const char *fname ) fname, lineno, 0 ); #endif } else { - be->be_glueflags |= SLAP_GLUE_SUBORDINATE; + be->be_flags |= SLAP_BFLAG_GLUE_SUBORDINATE; num_subordinates++; } @@ -1994,14 +1996,14 @@ read_config( const char *fname ) } if ( strcasecmp( cargv[1], "on" ) == 0 ) { if ( be ) - be->be_lastmod = ON; + be->be_flags |= SLAP_BFLAG_LASTMOD; else - global_lastmod = ON; + lastmod = ON; } else { if ( be ) - be->be_lastmod = OFF; + be->be_flags &= ~SLAP_BFLAG_LASTMOD; else - global_lastmod = OFF; + lastmod = OFF; } /* set idle timeout value */ diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 3262b5337a..d3d334d0ab 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -345,9 +345,7 @@ do_modify( goto cleanup; } - if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED && - global_lastmod == ON)) && !repl_user ) - { + if ( SLAP_LASTMOD(be) && !repl_user ) { for( modtail = &modlist; *modtail != NULL; modtail = &(*modtail)->sml_next ) diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 2495083af4..9e05b572ad 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -977,7 +977,6 @@ LDAP_SLAPD_V (const char) Versionstr[]; LDAP_SLAPD_V (struct slap_limits_set) deflimit; LDAP_SLAPD_V (slap_access_t) global_default_access; -LDAP_SLAPD_V (int) global_lastmod; LDAP_SLAPD_V (int) global_idletimeout; LDAP_SLAPD_V (int) global_schemacheck; LDAP_SLAPD_V (char *) global_host; diff --git a/servers/slapd/root_dse.c b/servers/slapd/root_dse.c index 4edcebbb80..d066423ed5 100644 --- a/servers/slapd/root_dse.c +++ b/servers/slapd/root_dse.c @@ -87,8 +87,9 @@ root_dse_info( attr_merge( e, ad_objectClass, vals ); for ( i = 0; i < nbackends; i++ ) { - if ( backends[i].be_glueflags & SLAP_GLUE_SUBORDINATE ) + if ( backends[i].be_flags & SLAP_BFLAG_GLUE_SUBORDINATE ) { continue; + } for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) { vals[0] = *backends[i].be_suffix[j]; attr_merge( e, ad_namingContexts, vals ); diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index ba66ff3903..f3410d9254 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1015,6 +1015,20 @@ struct slap_backend_db { #define be_sync bd_info->bi_tool_sync #endif +#define SLAP_BFLAG_LASTMOD 0x0001U + +#define SLAP_BFLAG_GLUE_INSTANCE 0x0010U /* a glue backend */ +#define SLAP_BFLAG_GLUE_SUBORDINATE 0x0020U /* child of a glue hierarchy */ +#define SLAP_BFLAG_GLUE_LINKED 0x00400 /* child is connected to parent */ + +#define SLAP_BFLAG_ALIASES 0x0010U +#define SLAP_BFLAG_MONITOR 0x0020U +#define SLAP_BFLAG_REFERRALS 0x0040U +#define SLAP_BFLAG_SUBENTRIES 0x0080U + + slap_mask_t be_flags; +#define SLAP_LASTMOD(be) ((be)->be_flags & SLAP_BFLAG_LASTMOD) + slap_mask_t be_restrictops; /* restriction operations */ #define SLAP_RESTRICT_OP_ADD 0x0001U #define SLAP_RESTRICT_OP_BIND 0x0002U @@ -1074,13 +1088,7 @@ struct slap_backend_db { struct berval be_update_ndn; /* allowed to make changes (in replicas) */ BVarray be_update_refs; /* where to refer modifying clients to */ char *be_realm; - int be_lastmod; /* keep track of lastmodified{by,time} */ - -#define SLAP_GLUE_INSTANCE 0x01 /* a glue backend */ -#define SLAP_GLUE_SUBORDINATE 0x02 /* child of a glue hierarchy */ -#define SLAP_GLUE_LINKED 0x04 /* child is connected to parent */ - int be_glueflags; /* */ void *be_private; /* anything the backend database needs */ }; @@ -1195,7 +1203,7 @@ typedef int (BI_tool_entry_reindex) LDAP_P(( BackendDB *be, ID id )); typedef int (BI_tool_sync) LDAP_P(( BackendDB *be )); struct slap_backend_info { - char *bi_type; /* type of backend */ + char *bi_type; /* type of backend */ /* * per backend type routines: diff --git a/servers/slapd/tools/slapcommon.c b/servers/slapd/tools/slapcommon.c index 030c1466f3..8343877c8e 100644 --- a/servers/slapd/tools/slapcommon.c +++ b/servers/slapd/tools/slapcommon.c @@ -232,7 +232,7 @@ slap_tool_init( /* If the named base is a glue master, operate on the * entire context */ - if (be->be_glueflags & SLAP_GLUE_INSTANCE) + if (be->be_flags & SLAP_BFLAG_GLUE_INSTANCE) nosubordinates = 1; } else if ( dbnum == -1 ) { @@ -240,7 +240,7 @@ slap_tool_init( /* If just doing the first by default and it is a * glue subordinate, find the master. */ - while (be->be_glueflags & SLAP_GLUE_SUBORDINATE) { + while (be->be_flags & SLAP_BFLAG_GLUE_SUBORDINATE) { nosubordinates = 1; be++; } -- 2.39.5