|
@@ -1152,10 +1152,6 @@ typedef struct tagTHREADNAME_INFO {
|
|
#include <sys/sendfile.h>
|
|
#include <sys/sendfile.h>
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-#if ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12)))
|
|
|
|
-#define GLIBC_CHK
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
static void mg_set_thread_name(const char *name)
|
|
static void mg_set_thread_name(const char *name)
|
|
{
|
|
{
|
|
char threadName[16]; /* Max. thread length in Linux/OSX/.. */
|
|
char threadName[16]; /* Max. thread length in Linux/OSX/.. */
|
|
@@ -1188,33 +1184,14 @@ static void mg_set_thread_name(const char *name)
|
|
__except(EXCEPTION_EXECUTE_HANDLER) {}
|
|
__except(EXCEPTION_EXECUTE_HANDLER) {}
|
|
#elif defined(__MINGW32__)
|
|
#elif defined(__MINGW32__)
|
|
/* No option known to set thread name for MinGW */
|
|
/* No option known to set thread name for MinGW */
|
|
- ;
|
|
|
|
#endif
|
|
#endif
|
|
-#elif defined(__linux__)
|
|
|
|
-/* Linux */
|
|
|
|
-#if defined(GLIBC_CHK)
|
|
|
|
|
|
+#elif ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12)))
|
|
|
|
+ /* pthread_setname_np first appeared in glibc in version 2.12*/
|
|
(void)pthread_setname_np(pthread_self(), threadName);
|
|
(void)pthread_setname_np(pthread_self(), threadName);
|
|
-#else
|
|
|
|
|
|
+#elif defined(__linux__)
|
|
|
|
+ /* 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);
|
|
#endif
|
|
#endif
|
|
-#elif defined(__APPLE__) || defined(__MACH__)
|
|
|
|
-/* OS X */
|
|
|
|
-#if defined(GLIBC_CHK)
|
|
|
|
- (void)pthread_setname_np(threadName);
|
|
|
|
-#endif
|
|
|
|
-#elif defined(BSD) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
|
|
|
-/* BSD (TODO: test) */
|
|
|
|
-#if defined(GLIBC_CHK)
|
|
|
|
- pthread_set_name_np(pthread_self(), threadName);
|
|
|
|
-#endif
|
|
|
|
-#elif defined(__AIX__) || defined(_AIX) || defined(__hpux) || defined(__sun)
|
|
|
|
-/* pthread_set_name_np seems to be missing on AIX, hpux, sun, ... */
|
|
|
|
-#else
|
|
|
|
-/* POSIX */
|
|
|
|
-#if defined(GLIBC_CHK)
|
|
|
|
- (void)pthread_setname_np(pthread_self(), threadName);
|
|
|
|
-#endif
|
|
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
#else /* !defined(NO_THREAD_NAME) */
|
|
#else /* !defined(NO_THREAD_NAME) */
|
|
void mg_set_thread_name(const char *threadName) {}
|
|
void mg_set_thread_name(const char *threadName) {}
|
|
@@ -8451,7 +8428,7 @@ static int parse_port_string(const struct vec *vec, struct socket *so)
|
|
|
|
|
|
static int set_ports_option(struct mg_context *ctx)
|
|
static int set_ports_option(struct mg_context *ctx)
|
|
{
|
|
{
|
|
- const char *list = ctx->config[LISTENING_PORTS];
|
|
|
|
|
|
+ const char *list;
|
|
int on = 1;
|
|
int on = 1;
|
|
#if defined(USE_IPV6)
|
|
#if defined(USE_IPV6)
|
|
int off = 0;
|
|
int off = 0;
|
|
@@ -8473,7 +8450,7 @@ static int set_ports_option(struct mg_context *ctx)
|
|
memset(&so, 0, sizeof(so));
|
|
memset(&so, 0, sizeof(so));
|
|
memset(&usa, 0, sizeof(usa));
|
|
memset(&usa, 0, sizeof(usa));
|
|
len = sizeof(usa);
|
|
len = sizeof(usa);
|
|
-
|
|
|
|
|
|
+ list = ctx->config[LISTENING_PORTS];
|
|
while ((list = next_option(list, &vec, NULL)) != NULL) {
|
|
while ((list = next_option(list, &vec, NULL)) != NULL) {
|
|
|
|
|
|
portsTotal++;
|
|
portsTotal++;
|