[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r34790 - in libmicrohttpd/src: include microhttpd platform
From: |
gnunet |
Subject: |
[GNUnet-SVN] r34790 - in libmicrohttpd/src: include microhttpd platform |
Date: |
Wed, 24 Dec 2014 20:00:33 +0100 |
Author: Karlson2k
Date: 2014-12-24 20:00:33 +0100 (Wed, 24 Dec 2014)
New Revision: 34790
Modified:
libmicrohttpd/src/include/w32functions.h
libmicrohttpd/src/microhttpd/daemon.c
libmicrohttpd/src/platform/w32functions.c
Log:
[w32] Set thread name
Modified: libmicrohttpd/src/include/w32functions.h
===================================================================
--- libmicrohttpd/src/include/w32functions.h 2014-12-24 19:00:23 UTC (rev
34789)
+++ libmicrohttpd/src/include/w32functions.h 2014-12-24 19:00:33 UTC (rev
34790)
@@ -194,6 +194,19 @@
/* Emulate snprintf function on W32 */
int W32_snprintf(char *__restrict s, size_t n, const char *__restrict format,
...);
+#ifndef _MSC_FULL_VER
+/* Thread name available only for VC-compiler */
+static void W32_SetThreadName(const DWORD thread_id, const char *thread_name)
+{ }
+#else /* _MSC_FULL_VER */
+/**
+ * Set thread name
+ * @param thread_id ID of thread, -1 for current thread
+ * @param thread_name name to set
+ */
+void W32_SetThreadName(const DWORD thread_id, const char *thread_name);
+#endif
+
#ifdef __cplusplus
}
#endif
Modified: libmicrohttpd/src/microhttpd/daemon.c
===================================================================
--- libmicrohttpd/src/microhttpd/daemon.c 2014-12-24 19:00:23 UTC (rev
34789)
+++ libmicrohttpd/src/microhttpd/daemon.c 2014-12-24 19:00:33 UTC (rev
34790)
@@ -1110,9 +1110,15 @@
errno = EINVAL;
return ret;
#elif defined(MHD_USE_W32_THREADS)
+ DWORD threadID;
*thread = CreateThread(NULL, daemon->thread_stack_size, start_routine,
- arg, 0, NULL);
- return (NULL != (*thread)) ? 0 : 1;
+ arg, 0, &threadID);
+ if (NULL == (*thread))
+ return EINVAL;
+
+ W32_SetThreadName(threadID, "libmicrohttpd");
+
+ return 0;
#endif
}
Modified: libmicrohttpd/src/platform/w32functions.c
===================================================================
--- libmicrohttpd/src/platform/w32functions.c 2014-12-24 19:00:23 UTC (rev
34789)
+++ libmicrohttpd/src/platform/w32functions.c 2014-12-24 19:00:33 UTC (rev
34790)
@@ -666,3 +666,39 @@
return ret;
}
+
+#ifdef _MSC_FULL_VER
+/**
+ * Set thread name
+ * @param thread_id ID of thread, -1 for current thread
+ * @param thread_name name to set
+ */
+void W32_SetThreadName(const DWORD thread_id, const char *thread_name)
+{
+ static const DWORD VC_SETNAME_EXC = 0x406D1388;
+#pragma pack(push,8)
+ struct thread_info_struct
+ {
+ DWORD type; // Must be 0x1000.
+ LPCSTR name; // Pointer to name (in user address space).
+ DWORD ID; // Thread ID (-1=caller thread).
+ DWORD flags; // Reserved for future use, must be zero.
+ } thread_info;
+#pragma pack(pop)
+
+ if (NULL == thread_name)
+ return;
+
+ thread_info.type = 0x1000;
+ thread_info.name = thread_name;
+ thread_info.ID = thread_id;
+ thread_info.flags = 0;
+
+ __try
+ { /* This exception is intercepted by debugger */
+ RaiseException(VC_SETNAME_EXC, 0, sizeof(thread_info) / sizeof(ULONG_PTR),
(ULONG_PTR*)&thread_info);
+ }
+ __except (EXCEPTION_EXECUTE_HANDLER)
+ {}
+}
+#endif /* _MSC_FULL_VER */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r34790 - in libmicrohttpd/src: include microhttpd platform,
gnunet <=