From 441ba52ffa996405c444b94ee6b8d56f6384ecff Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Tue, 24 Feb 2015 11:17:01 -0500 Subject: [PATCH] Ticket 48037 - ns_thrpool_new should take a config struct rather than many parameters Description: Use a config struct for all the thread pool configuration Also, fixed a shutdown crash when the the nunc-stans listener is disabled. https://fedorahosted.org/389/ticket/48037 Reviewed by: ? --- ldap/servers/slapd/connection.c | 2 +- ldap/servers/slapd/daemon.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c index 0ed6c7c..240b29c 100644 --- a/ldap/servers/slapd/connection.c +++ b/ldap/servers/slapd/connection.c @@ -278,7 +278,7 @@ connection_cleanup(Connection *conn) /* free the connection socket buffer */ connection_free_private_buffer(conn); - if (enable_listeners) { + if (enable_listeners && !g_get_shutdown()) { ns_enable_listeners(); } #ifdef ENABLE_NUNC_STANS diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index b0b83b2..65a254b 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -1260,6 +1260,7 @@ void slapd_daemon( daemon_ports_t *ports ) int in_referral_mode = config_check_referral_mode(); #ifdef ENABLE_NUNC_STANS ns_thrpool_t *tp; + struct ns_thrpool_config tp_config; #endif int connection_table_size = get_configured_connection_table_size(); the_connection_table= connection_table_new(connection_table_size); @@ -1451,7 +1452,14 @@ void slapd_daemon( daemon_ports_t *ports ) if (getenv("MAX_THREADS")) { maxthreads = atoi(getenv("MAX_THREADS")); } - tp = ns_thrpool_new(maxthreads, maxthreads, 0, 1024); + /* Set the nunc-stans thread pool config */ + tp_config.initial_threads = maxthreads; + tp_config.max_threads = maxthreads; + tp_config.stacksize = 0; + tp_config.event_queue_size = config_get_maxdescriptors(); + tp_config.work_queue_size = config_get_maxdescriptors(); + + tp = ns_thrpool_new(&tp_config); ns_add_signal_job(tp, SIGINT, NS_JOB_SIGNAL, ns_set_shutdown, NULL, NULL); ns_add_signal_job(tp, SIGTERM, NS_JOB_SIGNAL, ns_set_shutdown, NULL, NULL); ns_add_signal_job(tp, SIGHUP, NS_JOB_SIGNAL, ns_set_shutdown, NULL, NULL); -- 1.9.3