From eac3fc3737d5c8dca58b202d1bfa37ad1ecbda83 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 21 Apr 2005 12:45:25 +0000 Subject: [PATCH] Added some delete handlers --- servers/slapd/back-bdb/attr.c | 19 +++++++++++- servers/slapd/back-bdb/config.c | 50 ++++++++++++++++++++++++++++++ servers/slapd/back-bdb/proto-bdb.h | 3 ++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/servers/slapd/back-bdb/attr.c b/servers/slapd/back-bdb/attr.c index 50182015cc..42b2bc3c26 100644 --- a/servers/slapd/back-bdb/attr.c +++ b/servers/slapd/back-bdb/attr.c @@ -330,9 +330,26 @@ bdb_attr_index_unparse( struct bdb_info *bdb, BerVarray *bva ) avl_apply( bdb->bi_attrs, bdb_attr_index_unparser, bva, -1, AVL_INORDER ); } +static void +bdb_attrinfo_free( AttrInfo *ai ) +{ +#ifdef LDAP_COMP_MATCH + free( ai->ai_cr ); +#endif + free( ai ); +} + void bdb_attr_index_destroy( Avlnode *tree ) { - avl_free( tree, free ); + avl_free( tree, bdb_attrinfo_free ); } +void bdb_attr_index_free( struct bdb_info *bdb, AttributeDescription *ad ) +{ + AttrInfo *ai; + + ai = avl_delete( &bdb->bi_attrs, ad, ainfo_type_cmp ); + if ( ai ) + bdb_attrinfo_free( ai ); +} diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index e5658dd4b8..87c2e884fb 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -221,7 +221,50 @@ bdb_cf_gen(ConfigArgs *c) break; } return rc; + } else if ( c->op == LDAP_MOD_DELETE ) { + rc = 0; + switch( c->type ) { + /* single-valued no-ops */ + case BDB_LOCKD: + case BDB_SSTACK: + break; + + case BDB_CHKPT: + /* FIXME: should stop the checkpoint task too */ + bdb->bi_txn_cp = 0; + break; + case BDB_CONFIG: + rc = 1; + /* FIXME: delete values or the whole file? */ + break; + case BDB_DIRECTORY: + rc = 1; + /* FIXME: what does this mean? */ + break; + case BDB_NOSYNC: + bdb->bi_dbenv->set_flags( bdb->bi_dbenv, DB_TXN_NOSYNC, 0 ); + break; + case BDB_INDEX: { + AttributeDescription *ad = NULL; + struct berval bv, def = BER_BVC("default"); + char *ptr; + const char *text; + for (ptr = c->line; !isspace( *ptr ); ptr++); + bv.bv_val = c->line; + bv.bv_len = ptr - bv.bv_val; + if ( ber_bvmatch( &bv, &defbv )) { + bdb->bi_defaultmask = 0; + } else { + slap_bv2ad( &bv, &ad, &text ); + if ( ad ) + bdb_attr_index_free( bdb, ad ); + } + } + break; + } + return rc; } + switch( c->type ) { case BDB_CHKPT: bdb->bi_txn_cp = 1; @@ -282,6 +325,10 @@ bdb_cf_gen(ConfigArgs *c) bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC; else bdb->bi_dbenv_xflags &= ~DB_TXN_NOSYNC; + if ( bdb->bi_db_is_open ) { + bdb->bi_dbenv->set_flags( bdb->bi_dbenv, DB_TXN_NOSYNC, + c->value_int ); + } break; case BDB_INDEX: @@ -289,6 +336,9 @@ bdb_cf_gen(ConfigArgs *c) c->argc - 1, &c->argv[1] ); if( rc != LDAP_SUCCESS ) return 1; + /* FIXME: must run slapindex on the new attributes */ + if ( bdb->bi_db_is_open ) { + } break; case BDB_LOCKD: diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 31d289c260..99716d2079 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -33,6 +33,7 @@ LDAP_BEGIN_DECL #define bdb_attr_mask BDB_SYMBOL(attr_mask) #define bdb_attr_index_config BDB_SYMBOL(attr_index_config) #define bdb_attr_index_destroy BDB_SYMBOL(attr_index_destroy) +#define bdb_attr_index_free BDB_SYMBOL(attr_index_free) #define bdb_attr_index_unparse BDB_SYMBOL(attr_index_unparse) #ifdef LDAP_COMP_MATCH @@ -57,6 +58,8 @@ int bdb_attr_index_config LDAP_P(( struct bdb_info *bdb, void bdb_attr_index_unparse LDAP_P(( struct bdb_info *bdb, BerVarray *bva )); void bdb_attr_index_destroy LDAP_P(( Avlnode *tree )); +void bdb_attr_index_free LDAP_P(( struct bdb_info *bdb, + AttributeDescription *ad )); /* * config.c -- 2.39.5