From 6aa36375457daa267dd6dceab0cb4f14565c0fa0 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sun, 11 May 2003 07:03:48 +0000 Subject: [PATCH] Added SLAP_TOOL_READMAIN and SLAP_TOOL_READONLY slapMode flags. The rw arg to tool_entry_open comes too late for back-bdb to use. --- servers/slapd/back-bdb/init.c | 18 +++++++++++++++++- servers/slapd/back-bdb/tools.c | 2 ++ servers/slapd/slap.h | 2 ++ servers/slapd/tools/slapcommon.c | 2 ++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/servers/slapd/back-bdb/init.c b/servers/slapd/back-bdb/init.c index 59f002da15..41ecef07a0 100644 --- a/servers/slapd/back-bdb/init.c +++ b/servers/slapd/back-bdb/init.c @@ -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; } diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index 32d9bb5ff1..2d7c812910 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -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; } diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index ac054095db..9037d88696 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -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 */ diff --git a/servers/slapd/tools/slapcommon.c b/servers/slapd/tools/slapcommon.c index e8fe3dcbb8..7e8514f277 100644 --- a/servers/slapd/tools/slapcommon.c +++ b/servers/slapd/tools/slapcommon.c @@ -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: -- 2.39.5