]> git.sur5r.net Git - openldap/commitdiff
Added SLAP_TOOL_READMAIN and SLAP_TOOL_READONLY slapMode flags. The rw
authorHoward Chu <hyc@openldap.org>
Sun, 11 May 2003 07:03:48 +0000 (07:03 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 11 May 2003 07:03:48 +0000 (07:03 +0000)
arg to tool_entry_open comes too late for back-bdb to use.

servers/slapd/back-bdb/init.c
servers/slapd/back-bdb/tools.c
servers/slapd/slap.h
servers/slapd/tools/slapcommon.c

index 59f002da15e8fe8a363d41a9d8df577afa01e947..41ecef07a0837aa0110501f33f7588275543d922 100644 (file)
@@ -333,7 +333,7 @@ bdb_db_open( BackendDB *be )
                }
        }
 
-       flags = DB_THREAD | DB_CREATE | bdb->bi_db_opflags;
+       flags = DB_THREAD | bdb->bi_db_opflags;
 
        bdb->bi_databases = (struct bdb_db_info **) ch_malloc(
                BDB_INDICES * sizeof(struct bdb_db_info *) );
@@ -363,17 +363,32 @@ bdb_db_open( BackendDB *be )
                                bdb_bt_compare );
                        rc = db->bdi_db->set_pagesize( db->bdi_db,
                                BDB_ID2ENTRY_PAGESIZE );
+                       if ( slapMode & SLAP_TOOL_READMAIN ) {
+                               flags |= DB_RDONLY;
+                       } else {
+                               flags |= DB_CREATE;
+                       }
                } else {
                        rc = db->bdi_db->set_flags( db->bdi_db, 
                                DB_DUP | DB_DUPSORT );
 #ifndef BDB_HIER
                        rc = db->bdi_db->set_dup_compare( db->bdi_db,
                                bdb_bt_compare );
+                       if ( slapMode & SLAP_TOOL_READONLY ) {
+                               flags |= DB_RDONLY;
+                       } else {
+                               flags |= DB_CREATE;
+                       }
 #else
                        rc = db->bdi_db->set_dup_compare( db->bdi_db,
                                bdb_dup_compare );
                        rc = db->bdi_db->set_bt_compare( db->bdi_db,
                                bdb_bt_compare );
+                       if ( slapMode & (SLAP_TOOL_READONLY|SLAP_TOOL_READMAIN) ) {
+                               flags |= DB_RDONLY;
+                       } else {
+                               flags |= DB_CREATE;
+                       }
 #endif
                        rc = db->bdi_db->set_pagesize( db->bdi_db,
                                BDB_PAGESIZE );
@@ -410,6 +425,7 @@ bdb_db_open( BackendDB *be )
                        return rc;
                }
 
+               flags &= ~(DB_CREATE | DB_RDONLY);
                db->bdi_name = bdbi_databases[i].name;
                bdb->bi_databases[i] = db;
        }
index 32d9bb5ff1248fd8592eaa7efa9d07c5994a9a53..2d7c8129105d88858c376bdccb161bb325f016be 100644 (file)
@@ -454,6 +454,8 @@ done:
                e->e_id = NOID;
        }
        bdb_entry_release( &op, e, 0 );
+       TXN_CHECKPOINT( bi->bi_dbenv,
+                       bi->bi_txn_cp_kbyte, bi->bi_txn_cp_min, 0 );
 
        return rc;
 }
index ac054095db0255e30601064e080d68e1f4a3435f..9037d88696e5441c105ae739dfa27fba4cf5d846 100644 (file)
@@ -1219,6 +1219,8 @@ LDAP_SLAPD_V (int) slapMode;
 #define SLAP_MODE                      0x0003
 
 #define SLAP_TRUNCATE_MODE     0x0100
+#define        SLAP_TOOL_READMAIN      0x0200
+#define        SLAP_TOOL_READONLY      0x0400
 
 struct slap_replica_info {
        char *ri_host;                          /* supersedes be_replica */
index e8fe3dcbb8e527aba7a7db758693b4b82e646a81..7e8514f277f57b71cd4813b0aaa393496f6d76fb 100644 (file)
@@ -105,10 +105,12 @@ slap_tool_init(
 
        case SLAPINDEX:
                options = "b:cd:f:n:v";
+               mode |= SLAP_TOOL_READMAIN;
                break;
 
        case SLAPCAT:
                options = "b:cd:f:l:n:s:v";
+               mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
                break;
 
        default: