浏览代码

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: rmeggins(Thanks!)
Mark Reynolds 10 年之前
父节点
当前提交
97aff2af96
共有 2 个文件被更改,包括 10 次插入2 次删除
  1. 1 1
      ldap/servers/slapd/connection.c
  2. 9 1
      ldap/servers/slapd/daemon.c

+ 1 - 1
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

+ 9 - 1
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);