mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
ITS#7926 support multiple config cleanup functions per op
Prep for main changes
This commit is contained in:
parent
b0d7308371
commit
2f94318f06
@ -1958,7 +1958,7 @@ asyncmeta_back_cf_gen( ConfigArgs *c )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
c->ca_private = mt;
|
c->ca_private = mt;
|
||||||
c->cleanup = asyncmeta_cf_cleanup;
|
config_push_cleanup( c, asyncmeta_cf_cleanup );
|
||||||
} break;
|
} break;
|
||||||
case LDAP_BACK_CFG_SUBTREE_EX:
|
case LDAP_BACK_CFG_SUBTREE_EX:
|
||||||
case LDAP_BACK_CFG_SUBTREE_IN:
|
case LDAP_BACK_CFG_SUBTREE_IN:
|
||||||
|
@ -445,7 +445,7 @@ mdb_cf_gen( ConfigArgs *c )
|
|||||||
mdb->mi_flags |= MDB_RE_OPEN;
|
mdb->mi_flags |= MDB_RE_OPEN;
|
||||||
ch_free( mdb->mi_dbenv_home );
|
ch_free( mdb->mi_dbenv_home );
|
||||||
mdb->mi_dbenv_home = NULL;
|
mdb->mi_dbenv_home = NULL;
|
||||||
c->cleanup = mdb_cf_cleanup;
|
config_push_cleanup( c, mdb_cf_cleanup );
|
||||||
ldap_pvt_thread_pool_purgekey( mdb->mi_dbenv );
|
ldap_pvt_thread_pool_purgekey( mdb->mi_dbenv );
|
||||||
break;
|
break;
|
||||||
case MDB_DBNOSYNC:
|
case MDB_DBNOSYNC:
|
||||||
@ -462,7 +462,7 @@ mdb_cf_gen( ConfigArgs *c )
|
|||||||
rc = mdb_env_set_flags( mdb->mi_dbenv, mdb_envflags[i].mask, 0 );
|
rc = mdb_env_set_flags( mdb->mi_dbenv, mdb_envflags[i].mask, 0 );
|
||||||
if ( rc ) {
|
if ( rc ) {
|
||||||
mdb->mi_flags |= MDB_RE_OPEN;
|
mdb->mi_flags |= MDB_RE_OPEN;
|
||||||
c->cleanup = mdb_cf_cleanup;
|
config_push_cleanup( c, mdb_cf_cleanup );
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
mdb->mi_dbenv_flags ^= mdb_envflags[i].mask;
|
mdb->mi_dbenv_flags ^= mdb_envflags[i].mask;
|
||||||
@ -474,7 +474,7 @@ mdb_cf_gen( ConfigArgs *c )
|
|||||||
rc = mdb_env_set_flags( mdb->mi_dbenv, mdb_envflags[i].mask, 0 );
|
rc = mdb_env_set_flags( mdb->mi_dbenv, mdb_envflags[i].mask, 0 );
|
||||||
if ( rc ) {
|
if ( rc ) {
|
||||||
mdb->mi_flags |= MDB_RE_OPEN;
|
mdb->mi_flags |= MDB_RE_OPEN;
|
||||||
c->cleanup = mdb_cf_cleanup;
|
config_push_cleanup( c, mdb_cf_cleanup );
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
mdb->mi_dbenv_flags ^= mdb_envflags[i].mask;
|
mdb->mi_dbenv_flags ^= mdb_envflags[i].mask;
|
||||||
@ -498,7 +498,7 @@ mdb_cf_gen( ConfigArgs *c )
|
|||||||
}
|
}
|
||||||
mdb->mi_defaultmask = 0;
|
mdb->mi_defaultmask = 0;
|
||||||
mdb->mi_flags |= MDB_DEL_INDEX;
|
mdb->mi_flags |= MDB_DEL_INDEX;
|
||||||
c->cleanup = mdb_cf_cleanup;
|
config_push_cleanup( c, mdb_cf_cleanup );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
struct berval bv, def = BER_BVC("default");
|
struct berval bv, def = BER_BVC("default");
|
||||||
@ -535,7 +535,7 @@ mdb_cf_gen( ConfigArgs *c )
|
|||||||
|
|
||||||
ai->ai_indexmask |= MDB_INDEX_DELETING;
|
ai->ai_indexmask |= MDB_INDEX_DELETING;
|
||||||
mdb->mi_flags |= MDB_DEL_INDEX;
|
mdb->mi_flags |= MDB_DEL_INDEX;
|
||||||
c->cleanup = mdb_cf_cleanup;
|
config_push_cleanup( c, mdb_cf_cleanup );
|
||||||
}
|
}
|
||||||
|
|
||||||
bv.bv_val[ bv.bv_len ] = sep;
|
bv.bv_val[ bv.bv_len ] = sep;
|
||||||
@ -735,7 +735,7 @@ mdb_cf_gen( ConfigArgs *c )
|
|||||||
rc = 0;
|
rc = 0;
|
||||||
if ( rc ) {
|
if ( rc ) {
|
||||||
mdb->mi_flags |= MDB_RE_OPEN;
|
mdb->mi_flags |= MDB_RE_OPEN;
|
||||||
c->cleanup = mdb_cf_cleanup;
|
config_push_cleanup( c, mdb_cf_cleanup );
|
||||||
rc = 0;
|
rc = 0;
|
||||||
}
|
}
|
||||||
mdb->mi_dbenv_flags |= mdb_envflags[j].mask;
|
mdb->mi_dbenv_flags |= mdb_envflags[j].mask;
|
||||||
@ -757,7 +757,7 @@ mdb_cf_gen( ConfigArgs *c )
|
|||||||
if( rc != LDAP_SUCCESS ) return 1;
|
if( rc != LDAP_SUCCESS ) return 1;
|
||||||
if ( mdb->mi_flags & MDB_IS_OPEN ) {
|
if ( mdb->mi_flags & MDB_IS_OPEN ) {
|
||||||
mdb->mi_flags |= MDB_OPEN_INDEX;
|
mdb->mi_flags |= MDB_OPEN_INDEX;
|
||||||
c->cleanup = mdb_cf_cleanup;
|
config_push_cleanup( c, mdb_cf_cleanup );
|
||||||
if ( !mdb->mi_index_task ) {
|
if ( !mdb->mi_index_task ) {
|
||||||
/* Start the task as soon as we finish here. Set a long
|
/* Start the task as soon as we finish here. Set a long
|
||||||
* interval (10 hours) so that it only gets scheduled once.
|
* interval (10 hours) so that it only gets scheduled once.
|
||||||
@ -791,7 +791,7 @@ mdb_cf_gen( ConfigArgs *c )
|
|||||||
mdb->mi_readers = c->value_int;
|
mdb->mi_readers = c->value_int;
|
||||||
if ( mdb->mi_flags & MDB_IS_OPEN ) {
|
if ( mdb->mi_flags & MDB_IS_OPEN ) {
|
||||||
mdb->mi_flags |= MDB_RE_OPEN;
|
mdb->mi_flags |= MDB_RE_OPEN;
|
||||||
c->cleanup = mdb_cf_cleanup;
|
config_push_cleanup( c, mdb_cf_cleanup );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -799,7 +799,7 @@ mdb_cf_gen( ConfigArgs *c )
|
|||||||
mdb->mi_mapsize = c->value_ulong;
|
mdb->mi_mapsize = c->value_ulong;
|
||||||
if ( mdb->mi_flags & MDB_IS_OPEN ) {
|
if ( mdb->mi_flags & MDB_IS_OPEN ) {
|
||||||
mdb->mi_flags |= MDB_RE_OPEN;
|
mdb->mi_flags |= MDB_RE_OPEN;
|
||||||
c->cleanup = mdb_cf_cleanup;
|
config_push_cleanup( c, mdb_cf_cleanup );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2126,7 +2126,7 @@ meta_back_cf_gen( ConfigArgs *c )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
c->ca_private = mt;
|
c->ca_private = mt;
|
||||||
c->cleanup = meta_cf_cleanup;
|
config_push_cleanup( c, meta_cf_cleanup );
|
||||||
} break;
|
} break;
|
||||||
case LDAP_BACK_CFG_SUBTREE_EX:
|
case LDAP_BACK_CFG_SUBTREE_EX:
|
||||||
case LDAP_BACK_CFG_SUBTREE_IN:
|
case LDAP_BACK_CFG_SUBTREE_IN:
|
||||||
|
@ -113,7 +113,7 @@ wt_cf_gen( ConfigArgs *c )
|
|||||||
wi->wi_flags |= WT_OPEN_INDEX;
|
wi->wi_flags |= WT_OPEN_INDEX;
|
||||||
|
|
||||||
if ( wi->wi_flags & WT_IS_OPEN ) {
|
if ( wi->wi_flags & WT_IS_OPEN ) {
|
||||||
c->cleanup = wt_cf_cleanup;
|
config_push_cleanup( c, wt_cf_cleanup );
|
||||||
|
|
||||||
if ( !wi->wi_index_task ) {
|
if ( !wi->wi_index_task ) {
|
||||||
/* Start the task as soon as we finish here. Set a long
|
/* Start the task as soon as we finish here. Set a long
|
||||||
|
@ -563,6 +563,35 @@ config_get_vals(ConfigTable *cf, ConfigArgs *c)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
config_push_cleanup(ConfigArgs *ca, ConfigDriver *cleanup)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
/* silently ignore redundant push */
|
||||||
|
for (i=0; i < ca->num_cleanups; i++) {
|
||||||
|
if ( ca->cleanups[i] == cleanup )
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ca->num_cleanups >= SLAP_CONFIG_CLEANUP_MAX)
|
||||||
|
return -1;
|
||||||
|
ca->cleanups[ca->num_cleanups++] = cleanup;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
config_run_cleanup(ConfigArgs *ca)
|
||||||
|
{
|
||||||
|
int i, rc = 0;
|
||||||
|
|
||||||
|
for (i=0; i < ca->num_cleanups; i++) {
|
||||||
|
rc = ca->cleanups[i](ca);
|
||||||
|
if (rc)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
init_config_attrs(ConfigTable *ct) {
|
init_config_attrs(ConfigTable *ct) {
|
||||||
int i, code;
|
int i, code;
|
||||||
|
@ -168,8 +168,12 @@ typedef struct config_args_s {
|
|||||||
BackendInfo *bi;
|
BackendInfo *bi;
|
||||||
Entry *ca_entry; /* entry being modified */
|
Entry *ca_entry; /* entry being modified */
|
||||||
void *ca_private; /* anything */
|
void *ca_private; /* anything */
|
||||||
ConfigDriver *cleanup;
|
#ifndef SLAP_CONFIG_CLEANUP_MAX
|
||||||
|
#define SLAP_CONFIG_CLEANUP_MAX 16
|
||||||
|
#endif
|
||||||
|
ConfigDriver *cleanups[SLAP_CONFIG_CLEANUP_MAX];
|
||||||
ConfigType table; /* which config table did we come from */
|
ConfigType table; /* which config table did we come from */
|
||||||
|
int num_cleanups;
|
||||||
} ConfigArgs;
|
} ConfigArgs;
|
||||||
|
|
||||||
/* If lineno is zero, we have an actual LDAP Add request from a client.
|
/* If lineno is zero, we have an actual LDAP Add request from a client.
|
||||||
@ -195,6 +199,9 @@ int config_del_vals(ConfigTable *cf, ConfigArgs *c);
|
|||||||
int config_get_vals(ConfigTable *ct, ConfigArgs *c);
|
int config_get_vals(ConfigTable *ct, ConfigArgs *c);
|
||||||
int config_add_vals(ConfigTable *ct, ConfigArgs *c);
|
int config_add_vals(ConfigTable *ct, ConfigArgs *c);
|
||||||
|
|
||||||
|
int config_push_cleanup(ConfigArgs *c, ConfigDriver *cleanup);
|
||||||
|
int config_run_cleanup(ConfigArgs *c);
|
||||||
|
|
||||||
void init_config_argv( ConfigArgs *c );
|
void init_config_argv( ConfigArgs *c );
|
||||||
int init_config_attrs(ConfigTable *ct);
|
int init_config_attrs(ConfigTable *ct);
|
||||||
int init_config_ocs( ConfigOCs *ocs );
|
int init_config_ocs( ConfigOCs *ocs );
|
||||||
|
@ -3781,7 +3781,7 @@ pc_ldadd( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
|
|||||||
ca->be = &cm->db;
|
ca->be = &cm->db;
|
||||||
/* Defer open if this is an LDAPadd */
|
/* Defer open if this is an LDAPadd */
|
||||||
if ( CONFIG_ONLINE_ADD( ca ))
|
if ( CONFIG_ONLINE_ADD( ca ))
|
||||||
ca->cleanup = pc_ldadd_cleanup;
|
config_push_cleanup( ca, pc_ldadd_cleanup );
|
||||||
else
|
else
|
||||||
cm->defer_db_open = 0;
|
cm->defer_db_open = 0;
|
||||||
ca->ca_private = on;
|
ca->ca_private = on;
|
||||||
|
@ -146,7 +146,7 @@ translucent_ldadd( CfEntryInfo *cei, Entry *e, ConfigArgs *ca )
|
|||||||
ca->be = &ov->db;
|
ca->be = &ov->db;
|
||||||
ca->ca_private = on;
|
ca->ca_private = on;
|
||||||
if ( CONFIG_ONLINE_ADD( ca ))
|
if ( CONFIG_ONLINE_ADD( ca ))
|
||||||
ca->cleanup = translucent_ldadd_cleanup;
|
config_push_cleanup( ca, translucent_ldadd_cleanup );
|
||||||
else
|
else
|
||||||
ov->defer_db_open = 0;
|
ov->defer_db_open = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user