Browse Source

Merge branch 'master' of https://github.com/civetweb/civetweb

bel2125 6 years ago
parent
commit
5e4fc3ab4c
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/civetweb.c

+ 5 - 0
src/civetweb.c

@@ -2976,7 +2976,12 @@ mg_set_thread_name(const char *name)
 #elif defined(_GNU_SOURCE) && defined(__GLIBC__)                               \
 #elif defined(_GNU_SOURCE) && defined(__GLIBC__)                               \
     && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12)))
     && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12)))
 	/* pthread_setname_np first appeared in glibc in version 2.12*/
 	/* pthread_setname_np first appeared in glibc in version 2.12*/
+#if defined(__MACH__)
+	/* OS X only current thread name can be changed */
+	(void)pthread_setname_np(threadName);
+#else
 	(void)pthread_setname_np(pthread_self(), threadName);
 	(void)pthread_setname_np(pthread_self(), threadName);
+#endif
 #elif defined(__linux__)
 #elif defined(__linux__)
 	/* on linux we can use the old prctl function */
 	/* on linux we can use the old prctl function */
 	(void)prctl(PR_SET_NAME, threadName, 0, 0, 0);
 	(void)prctl(PR_SET_NAME, threadName, 0, 0, 0);