diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2017-04-28 17:43:46 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2017-04-28 17:43:46 -0400 |
commit | 5afc2767e74ad25113b2c36be7b18484f156f525 (patch) | |
tree | e6e163ba6c868ab279cb35be0c3595c97716e137 | |
parent | 4945cdd909c91b4e155a17a07d6766f9ca88be9f (diff) | |
download | mongo-5afc2767e74ad25113b2c36be7b18484f156f525.tar.gz |
SERVER-27279 pthread_setname_np is not supported on SUSE 11.4
(cherry picked from commit 37cbe92c62a7ec2bbad615cc11098c30acd49038)
-rw-r--r-- | SConstruct | 28 | ||||
-rw-r--r-- | src/mongo/SConscript | 7 | ||||
-rw-r--r-- | src/mongo/config.h.in | 15 | ||||
-rw-r--r-- | src/mongo/util/concurrency/thread_name.cpp | 2 |
4 files changed, 42 insertions, 10 deletions
diff --git a/SConstruct b/SConstruct index bb23b1287cb..5365fcb7969 100644 --- a/SConstruct +++ b/SConstruct @@ -2622,6 +2622,34 @@ def doConfigure(myenv): conf = Configure(myenv, custom_tests = { 'CheckBoostMinVersion': CheckBoostMinVersion, }) + + # pthread_setname_np was added in GLIBC 2.12, and Solaris 11.3 + if posix_system: + myenv = conf.Finish() + + def CheckPThreadSetNameNP(context): + compile_test_body = textwrap.dedent(""" + #define _GNU_SOURCE + #include <pthread.h> + + int main() { + pthread_setname_np(pthread_self(), "test"); + return 0; + } + """) + + context.Message("Checking if pthread_setname_np is supported... ") + result = context.TryCompile(compile_test_body, ".c") + context.Result(result) + return result + + conf = Configure(myenv, custom_tests = { + 'CheckPThreadSetNameNP': CheckPThreadSetNameNP, + }) + + if conf.CheckPThreadSetNameNP(): + conf.env.SetConfigHeaderDefine("MONGO_CONFIG_HAVE_PTHREAD_SETNAME_NP") + libdeps.setup_conftests(conf) def addOpenSslLibraryToDistArchive(file_name): diff --git a/src/mongo/SConscript b/src/mongo/SConscript index 0a470310ec6..62c17a7ecd1 100644 --- a/src/mongo/SConscript +++ b/src/mongo/SConscript @@ -243,7 +243,6 @@ if env.TargetOSIs('windows'): config_header_substs = ( ('@mongo_config_byte_order@', 'MONGO_CONFIG_BYTE_ORDER'), ('@mongo_config_debug_build@', 'MONGO_CONFIG_DEBUG_BUILD'), - ('@mongo_config_have_thread_local@', 'MONGO_CONFIG_HAVE_THREAD_LOCAL'), ('@mongo_config_have___declspec_thread@', 'MONGO_CONFIG_HAVE___DECLSPEC_THREAD'), ('@mongo_config_have___thread@', 'MONGO_CONFIG_HAVE___THREAD'), ('@mongo_config_have_execinfo_backtrace@', 'MONGO_CONFIG_HAVE_EXECINFO_BACKTRACE'), @@ -251,11 +250,13 @@ config_header_substs = ( ('@mongo_config_have_header_unistd_h@', 'MONGO_CONFIG_HAVE_HEADER_UNISTD_H'), ('@mongo_config_have_memset_s@', 'MONGO_CONFIG_HAVE_MEMSET_S'), ('@mongo_config_have_posix_monotonic_clock@', 'MONGO_CONFIG_HAVE_POSIX_MONOTONIC_CLOCK'), - ('@mongo_config_have_std_is_trivially_copyable@', 'MONGO_CONFIG_HAVE_STD_IS_TRIVIALLY_COPYABLE'), + ('@mongo_config_have_pthread_setname_np@', 'MONGO_CONFIG_HAVE_PTHREAD_SETNAME_NP'), + ('@mongo_config_have_std_align@', 'MONGO_CONFIG_HAVE_STD_ALIGN'), ('@mongo_config_have_std_enable_if_t@', 'MONGO_CONFIG_HAVE_STD_ENABLE_IF_T'), + ('@mongo_config_have_std_is_trivially_copyable@', 'MONGO_CONFIG_HAVE_STD_IS_TRIVIALLY_COPYABLE'), ('@mongo_config_have_std_make_unique@', 'MONGO_CONFIG_HAVE_STD_MAKE_UNIQUE'), - ('@mongo_config_have_std_align@', 'MONGO_CONFIG_HAVE_STD_ALIGN'), ('@mongo_config_have_strnlen@', 'MONGO_CONFIG_HAVE_STRNLEN'), + ('@mongo_config_have_thread_local@', 'MONGO_CONFIG_HAVE_THREAD_LOCAL'), ('@mongo_config_optimized_build@', 'MONGO_CONFIG_OPTIMIZED_BUILD'), ('@mongo_config_ssl@', 'MONGO_CONFIG_SSL'), ('@mongo_config_ssl_has_asn1_any_definitions@', 'MONGO_CONFIG_HAVE_ASN1_ANY_DEFINITIONS'), diff --git a/src/mongo/config.h.in b/src/mongo/config.h.in index e7e70a434a2..c1ef64647b0 100644 --- a/src/mongo/config.h.in +++ b/src/mongo/config.h.in @@ -34,9 +34,6 @@ // Define if building a debug build @mongo_config_debug_build@ -// Defined if thread_local storage class is available -@mongo_config_have_thread_local@ - // Defined if __declspec(thread) is available @mongo_config_have___declspec_thread@ @@ -58,18 +55,24 @@ // Defined if a POSIX monotonic clock is available @mongo_config_have_posix_monotonic_clock@ +// Defined if pthread.h and pthread_setname_np are available +@mongo_config_have_pthread_setname_np@ + +// Defined if std::align is available +@mongo_config_have_std_align@ + // Defined if std::is_trivially_copyable is available @mongo_config_have_std_is_trivially_copyable@ // Defined if std::make_unique is available @mongo_config_have_std_make_unique@ -// Defined if std::align is available -@mongo_config_have_std_align@ - // Defined if strnlen is available @mongo_config_have_strnlen@ +// Defined if thread_local storage class is available +@mongo_config_have_thread_local@ + // Defined if building an optimized build @mongo_config_optimized_build@ diff --git a/src/mongo/util/concurrency/thread_name.cpp b/src/mongo/util/concurrency/thread_name.cpp index 670494caab8..81b2135ae48 100644 --- a/src/mongo/util/concurrency/thread_name.cpp +++ b/src/mongo/util/concurrency/thread_name.cpp @@ -114,7 +114,7 @@ void setThreadName(StringData name) { if (error) { log() << "Ignoring error from setting thread name: " << errnoWithDescription(error); } -#elif defined(__linux__) +#elif defined(__linux__) && defined(MONGO_CONFIG_HAVE_PTHREAD_SETNAME_NP) // Maximum thread name length supported on Linux is 16 including the null terminator. Ideally // we use short and descriptive thread names that fit: this helps for log readibility as well. // Since several components set verbose thread names with a uniqifier at the end, we do a split |