From fc621a1c784f8307e339148b04b8c6c1e0406c32 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 27 Oct 2005 09:29:42 +0000 Subject: [PATCH] Add tool-threads config keyword, init thread pool in tool mode. --- servers/slapd/bconfig.c | 14 ++++++++++++++ servers/slapd/init.c | 6 ++++-- servers/slapd/proto-slap.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index ea679bad6e..8b66270c0f 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -163,6 +163,7 @@ enum { CFG_SASLSECP, CFG_SSTR_IF_MAX, CFG_SSTR_IF_MIN, + CFG_TTHREADS, CFG_LAST }; @@ -570,6 +571,9 @@ static ConfigTable config_back_cf_table[] = { #endif "( OLcfgGlAt:77 NAME 'olcTLSDHParamDir' " "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL }, + { "tool-threads", "count", 2, 2, 0, ARG_INT|ARG_MAGIC|CFG_TTHREADS, + &config_generic, "( OLcfgGlAt:80 NAME 'olcToolThreads' " + "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, { "ucdata-path", "path", 2, 2, 0, ARG_IGNORED, NULL, NULL, NULL, NULL }, { "updatedn", "dn", 2, 2, 0, ARG_DB|ARG_DN|ARG_QUOTE|ARG_MAGIC, @@ -628,6 +632,7 @@ static ConfigOCs cf_ocs[] = { "olcTLSCACertificatePath $ olcTLSCertificateFile $ " "olcTLSCertificateKeyFile $ olcTLSCipherSuite $ olcTLSCRLCheck $ " "olcTLSRandFile $ olcTLSVerifyClient $ olcTLSDHParamDir $ " + "olcToolThreads $ " "olcObjectIdentifier $ olcAttributeTypes $ olcObjectClasses $ " "olcDitContentRules ) )", Cft_Global }, { "( OLcfgGlOc:2 " @@ -700,6 +705,9 @@ config_generic(ConfigArgs *c) { case CFG_THREADS: c->value_int = connection_pool_max; break; + case CFG_TTHREADS: + c->value_int = slap_tool_thread_max; + break; case CFG_SALT: if ( passwd_salt ) c->value_string = ch_strdup( passwd_salt ); @@ -909,6 +917,7 @@ config_generic(ConfigArgs *c) { /* single-valued attrs, no-ops */ case CFG_CONCUR: case CFG_THREADS: + case CFG_TTHREADS: case CFG_RO: case CFG_AZPOLICY: case CFG_DEPTH: @@ -1022,6 +1031,11 @@ config_generic(ConfigArgs *c) { connection_pool_max = c->value_int; /* save for reference */ break; + case CFG_TTHREADS: + ldap_pvt_thread_pool_maxthreads(&connection_pool, c->value_int); + slap_tool_thread_max = c->value_int; /* save for reference */ + break; + case CFG_SALT: if ( passwd_salt ) ch_free( passwd_salt ); passwd_salt = c->value_string; diff --git a/servers/slapd/init.c b/servers/slapd/init.c index ab5f17b7a7..6a68e498ee 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -67,6 +67,7 @@ struct berval NoAttrs = BER_BVC( LDAP_NO_ATTRS ); */ ldap_pvt_thread_pool_t connection_pool; int connection_pool_max = SLAP_MAX_WORKER_THREADS; +int slap_tool_thread_max = 1; #ifndef HAVE_GMTIME_R ldap_pvt_thread_mutex_t gmtime_mutex; #endif @@ -124,8 +125,6 @@ slap_init( int mode, const char *name ) switch ( slapMode & SLAP_MODE ) { case SLAP_SERVER_MODE: - ldap_pvt_thread_pool_init( &connection_pool, - connection_pool_max, 0); /* FALLTHRU */ case SLAP_TOOL_MODE: @@ -136,6 +135,9 @@ slap_init( int mode, const char *name ) slap_name = name; + ldap_pvt_thread_pool_init( &connection_pool, + connection_pool_max, 0); + ldap_pvt_thread_mutex_init( &entry2str_mutex ); ldap_pvt_thread_mutex_init( &replog_mutex ); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index d9c0ab2436..b4cea81cf1 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1734,6 +1734,7 @@ LDAP_SLAPD_V (time_t) starttime; LDAP_SLAPD_V (ldap_pvt_thread_pool_t) connection_pool; LDAP_SLAPD_V (int) connection_pool_max; +LDAP_SLAPD_V (int) slap_tool_thread_max; LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) entry2str_mutex; LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) replog_mutex; -- 2.39.5