summaryrefslogtreecommitdiff
path: root/platform/default
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-07-14 19:57:02 +0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2016-07-16 10:38:42 +0300
commit4d9e824639282fe0c263b3e29c25cba549673e85 (patch)
treeebe399917870e9cf03cc541eff015095e31bfb0c /platform/default
parent4a1a7937ae795b46c885fd3edf871fe8cbb2468e (diff)
downloadqtlocation-mapboxgl-4d9e824639282fe0c263b3e29c25cba549673e85.tar.gz
[core] Trim thread name on Linux to 16 bytes
That is a hard limit, if you set a string bigger than that, it doesn't get set.
Diffstat (limited to 'platform/default')
-rw-r--r--platform/default/thread.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/platform/default/thread.cpp b/platform/default/thread.cpp
index d398bc926b..a217bc73f4 100644
--- a/platform/default/thread.cpp
+++ b/platform/default/thread.cpp
@@ -26,7 +26,11 @@ void setCurrentThreadName(const std::string& name) {
pthread_setname_np(name.c_str());
#elif defined(__GLIBC__) && defined(__GLIBC_PREREQ)
#if __GLIBC_PREREQ(2, 12)
- pthread_setname_np(pthread_self(), name.c_str());
+ if (name.size() > 15) { // Linux hard limit (see manpages).
+ pthread_setname_np(pthread_self(), name.substr(0, 15).c_str());
+ } else {
+ pthread_setname_np(pthread_self(), name.c_str());
+ }
#endif
#endif
(void)name;