]> git.sur5r.net Git - openldap/commitdiff
Rework backend (lastmod + glue + system schema) flags
authorKurt Zeilenga <kurt@openldap.org>
Thu, 10 Jan 2002 22:34:11 +0000 (22:34 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 10 Jan 2002 22:34:11 +0000 (22:34 +0000)
servers/slapd/add.c
servers/slapd/backend.c
servers/slapd/backglue.c
servers/slapd/config.c
servers/slapd/modify.c
servers/slapd/proto-slap.h
servers/slapd/root_dse.c
servers/slapd/slap.h
servers/slapd/tools/slapcommon.c

index e167eb5b1ae18edccd36b43a9b5ed57370131cf6..426ff27b578cc0b01ec1cafe189f3674caced5d9 100644 (file)
@@ -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 )
index 61bfb2ae0445784647f14e1ec10b7215a096c45d..3c5d842059471af4b69bcc38f9ae256e25324d86 100644 (file)
@@ -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;
index e7299d7511f7a82f82a5ee7a6d9cf7347a0c6459..f7f68ffeec84014f12eb595fe66d20e11f2c4589 100644 (file)
@@ -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;
index 93a9934344dd21e6a82a9817c35da4e66d3a1856..221ef9c22a78f6c6a54f2e69877f2df63e47ea06 100644 (file)
@@ -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 */
index 3262b5337aa7c7996aacc583d390fe8987452914..d3d334d0abf1b95caffa4dc7d4646165c01457dc 100644 (file)
@@ -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 )
index 2495083af42d43b19433a19953979a29302a9f3c..9e05b572add27724c9fadc0199aeae5f49c6e778 100644 (file)
@@ -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;
index 4edcebbb8004425e8b8595a4b514fde1d1fc3fb2..d066423ed52c4ca6930fc17c50c867a29736febc 100644 (file)
@@ -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 );
index ba66ff390330a781c6b9bfb38bf24e88c78d1dff..f3410d9254e9fc7a6246c85a65b21e025dab3041 100644 (file)
@@ -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:
index 030c1466f3d313fa10fb508946d93142d10aafe0..8343877c8e50a0b5d7baa71f69bd1254ad77ef47 100644 (file)
@@ -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++;
                }