diff --git a/server/core/config.c b/server/core/config.c index da646f8fd..6937244c3 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -75,6 +75,7 @@ #include #include #include +#include #define PCRE2_CODE_UNIT_WIDTH 8 #include @@ -895,8 +896,8 @@ handle_global_item(const char *name, const char *value) int processor_count = get_processor_count(); if (thrcount > processor_count) { - MXS_WARNING("Number of threads set to %d which is greater than" - " the number of processors available: %d", + MXS_WARNING("Number of threads set to %d, which is greater than " + "the number of processors available: %d", thrcount, processor_count); } } @@ -906,6 +907,14 @@ handle_global_item(const char *name, const char *value) return 0; } } + + if (gateway.n_threads > MXS_MAX_THREADS) + { + MXS_WARNING("Number of threads set to %d, which is greater than the " + "hard maximum of %d. Number of threads adjusted down " + "accordingly.", gateway.n_threads, MXS_MAX_THREADS); + gateway.n_threads = MXS_MAX_THREADS; + } } else if (strcmp(name, "non_blocking_polls") == 0) { diff --git a/server/include/gwbitmask.h b/server/include/gwbitmask.h index 7b69c4199..782798907 100644 --- a/server/include/gwbitmask.h +++ b/server/include/gwbitmask.h @@ -12,7 +12,9 @@ * of this software will be governed by version 2 or later of the General * Public License. */ + #include +#include /** * @file gwbitmask.h An implementation of an arbitrarily long bitmask @@ -28,7 +30,7 @@ */ /* This number MUST an be exact multiple of 8 */ -#define MXS_BITMASK_LENGTH 256 /**< Number of bits in the bitmask */ +#define MXS_BITMASK_LENGTH (MXS_MAX_THREADS + 1) /**< Number of bits in the bitmask */ #define MXS_BITMASK_SIZE (MXS_BITMASK_LENGTH / 8) /**< Number of bytes in the bitmask */ diff --git a/server/include/maxscale/limits.h b/server/include/maxscale/limits.h new file mode 100644 index 000000000..083a255dc --- /dev/null +++ b/server/include/maxscale/limits.h @@ -0,0 +1,24 @@ +#ifndef _MAXSCALE_LIMITS_H +#define _MAXSCALE_LIMITS_H +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl. + * + * Change Date: 2019-07-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +// This file defines hard limits of MaxScale. + +// Thread information is stored in a bitmask whose size must be a +// multiple of 8. The bitmask is indexed using the thread id that start +// from 1. Hence, the hard maximum number of threads must be a +// multiple of 8 minus 1. +#define MXS_MAX_THREADS 255 + +#endif