Updated Branches: refs/heads/master 8cd9b6520 -> 066cf33d7
TS-1035 EventProcessor::spawn_thread doesn't check that there is enough event threads and segfaults Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/066cf33d Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/066cf33d Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/066cf33d Branch: refs/heads/master Commit: 066cf33d76ab2f14cf033854d706696e5bb8513b Parents: 8cd9b65 Author: Brian Geffon <[email protected]> Authored: Sat Jan 28 17:01:35 2012 -0800 Committer: Brian Geffon <[email protected]> Committed: Sat Jan 28 17:01:35 2012 -0800 ---------------------------------------------------------------------- CHANGES | 2 + configure.ac | 28 +++++++++++++++++++++++++ iocore/eventsystem/I_EventProcessor.h | 13 +++++++++- iocore/eventsystem/UnixEventProcessor.cc | 1 + lib/ts/ink_config.h.in | 7 ++++++ mgmt/BaseManager.h | 2 +- mgmt/LocalManager.cc | 2 +- proxy/Main.cc | 6 ++-- 8 files changed, 54 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/066cf33d/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 27569fa..551d651 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,7 @@ -*- coding: utf-8 -*- Changes with Apache Traffic Server 3.1.2 + *) [TS-1035] EventProcessor::spawn_thread doesn't check that there + is enough event threads and segfaults. Author: Brian Geffon *) [TS-1096] readline support for traffic_shell. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/066cf33d/configure.ac ---------------------------------------------------------------------- diff --git a/configure.ac b/configure.ac index f44ef07..4f8b2e1 100644 --- a/configure.ac +++ b/configure.ac @@ -409,6 +409,25 @@ AC_ARG_WITH([max-api-stats], AC_SUBST(max_api_stats) # +# EventProcessor thread configurations +# + +AC_ARG_WITH([max-event-threads], + [AS_HELP_STRING([--with-max-event-threads],[max number of event threads [default=4096]])], + [max_event_threads=$withval], + [max_event_threads=4096] +) +AC_SUBST(max_event_threads) + +AC_ARG_WITH([max-threads-per-type], + [AS_HELP_STRING([--with-max-threads-per-type],[max number of threads per event type [default=3072]])], + [max_threads_per_type=$withval], + [max_threads_per_type=3072] +) +AC_SUBST(max_threads_per_type) + + +# # Installation directories # For each var the following is evaluated # foo Standard variable eg. ${prefix}/foo @@ -1018,6 +1037,15 @@ TS_CHECK_JEMALLOC TS_CHECK_TCMALLOC # +# Determine ARG_MAX +# Default to 2048 if we cannot resolve ARG_MAX for some reason +arg_max="`getconf ARG_MAX`" +if test "x${arg_max}" = x ; then + arg_max=2048 +fi +AC_SUBST(arg_max) + +# # Check for libreadline/libedit AX_LIB_READLINE http://git-wip-us.apache.org/repos/asf/trafficserver/blob/066cf33d/iocore/eventsystem/I_EventProcessor.h ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/I_EventProcessor.h b/iocore/eventsystem/I_EventProcessor.h index 4cc16b0..f33f5a3 100644 --- a/iocore/eventsystem/I_EventProcessor.h +++ b/iocore/eventsystem/I_EventProcessor.h @@ -29,8 +29,17 @@ #include "I_Processor.h" #include "I_Event.h" -const int MAX_THREADS_IN_EACH_TYPE = 512; -const int MAX_EVENT_THREADS = 512; +#ifdef TS_MAX_THREADS_IN_EACH_THREAD_TYPE +const int MAX_THREADS_IN_EACH_TYPE = TS_MAX_THREADS_IN_EACH_THREAD_TYPE; +#else +const int MAX_THREADS_IN_EACH_TYPE = 3072; +#endif + +#ifdef TS_MAX_NUMBER_EVENT_THREADS +const int MAX_EVENT_THREADS = TS_MAX_NUMBER_EVENT_THREADS; +#else +const int MAX_EVENT_THREADS = 4096; +#endif class EThread; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/066cf33d/iocore/eventsystem/UnixEventProcessor.cc ---------------------------------------------------------------------- diff --git a/iocore/eventsystem/UnixEventProcessor.cc b/iocore/eventsystem/UnixEventProcessor.cc index d7a501d..a3b5a7b 100644 --- a/iocore/eventsystem/UnixEventProcessor.cc +++ b/iocore/eventsystem/UnixEventProcessor.cc @@ -110,6 +110,7 @@ EventProcessor::shutdown() Event * EventProcessor::spawn_thread(Continuation *cont, const char* thr_name, ink_sem *sem) { + ink_release_assert(n_dthreads < MAX_EVENT_THREADS); Event *e = eventAllocator.alloc(); e->init(cont, 0, 0); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/066cf33d/lib/ts/ink_config.h.in ---------------------------------------------------------------------- diff --git a/lib/ts/ink_config.h.in b/lib/ts/ink_config.h.in index a2d6df7..7725896 100644 --- a/lib/ts/ink_config.h.in +++ b/lib/ts/ink_config.h.in @@ -148,6 +148,13 @@ # define USE_MD5_FOR_MMH 1 #endif +# define TS_MAX_THREADS_IN_EACH_THREAD_TYPE @max_threads_per_type@ +# define TS_MAX_NUMBER_EVENT_THREADS @max_event_threads@ + +# define TS_ARG_MAX @arg_max@ +# define TS_ARG_MAX_STR "@arg_max@" + + #if TS_HAS_INKAPI #define TS_MAX_API_STATS @max_api_stats@ /* XXX: Should make those individually selectable ? */ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/066cf33d/mgmt/BaseManager.h ---------------------------------------------------------------------- diff --git a/mgmt/BaseManager.h b/mgmt/BaseManager.h index c7379da..a8d268c 100644 --- a/mgmt/BaseManager.h +++ b/mgmt/BaseManager.h @@ -45,7 +45,7 @@ * used by LocalManager and in Proxy Main. * */ #define MAX_OPTION_SIZE 2048 -#define MAX_PROXY_SERVER_PORTS 48 +#define MAX_PROXY_SERVER_PORTS 2048 #define MAX_ATTR_LEN 5 /*******************************************/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/066cf33d/mgmt/LocalManager.cc ---------------------------------------------------------------------- diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc index ffe4685..efce1cb 100644 --- a/mgmt/LocalManager.cc +++ b/mgmt/LocalManager.cc @@ -1001,7 +1001,7 @@ LocalManager::startProxy() RecSetRecordInt("proxy.node.restarts.proxy.restart_count", proxy_launch_count); } else { int res, i = 0, n; - char real_proxy_options[2048], *options[32], *last, *tok; + char real_proxy_options[TS_ARG_MAX], *options[32], *last, *tok; bool open_ports_p = false; snprintf(real_proxy_options, sizeof(real_proxy_options), "%s", proxy_options); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/066cf33d/proxy/Main.cc ---------------------------------------------------------------------- diff --git a/proxy/Main.cc b/proxy/Main.cc index 0845066..73f2598 100644 --- a/proxy/Main.cc +++ b/proxy/Main.cc @@ -134,10 +134,10 @@ int num_of_udp_threads = DEFAULT_NUMBER_OF_UDP_THREADS; int num_accept_threads = DEFAULT_NUM_ACCEPT_THREADS; int num_task_threads = DEFAULT_NUM_TASK_THREADS; int run_test_hook = 0; -char http_accept_port_descriptor[1023] = ""; +char http_accept_port_descriptor[TS_ARG_MAX + 1] = ""; +#define TS_ARG_MAX_STR_FMT "S" TS_ARG_MAX_STR int http_accept_file_descriptor = NO_FD; int ssl_accept_file_descriptor = NO_FD; -char accept_fd_list[1024] = ""; char core_file[255] = ""; bool enable_core_file_p = false; // Enable core file dump? int command_flag = DEFAULT_COMMAND_FLAG; @@ -208,7 +208,7 @@ ArgumentDescription argument_descriptions[] = { "PROXY_ACCEPT_THREAD", NULL}, {"accept_till_done", 'b', "Accept Till Done", "T", &accept_till_done, "PROXY_ACCEPT_TILL_DONE", NULL}, - {"httpport", 'p', "Port descriptor for HTTP Accept", "S1023", + {"httpport", 'p', "Port descriptor for HTTP Accept", TS_ARG_MAX_STR_FMT, http_accept_port_descriptor, "PROXY_HTTP_ACCEPT_PORT", NULL}, {"cluster_port", 'P', "Cluster Port Number", "I", &cluster_port_number, "PROXY_CLUSTER_PORT", NULL},
