[bitcoin/bitcoin] Thread names in logs and deadlock debug tools (take 2) (#13168)

sipa commented on this pull request.

> +#include
+#include +
+#include +
+/*
+ * TODO: using thread_local changes the abi in ways that may not play nice
+ * when the c++ stdlib is linked dynamically. Disable it until thorough
+ * testing has been done.
+ *
+ * mingw32’s implementation of thread_local has also been shown to behave
+ * erroneously under concurrent usage; see:
+ *
+ * https://gist.github.com/jamesob/fe9a872051a88b2025b1aa37bfa98605
+ */
+#undef HAVE_THREAD_LOCAL

I think this line may be unintentional.

> +#elif defined(MAC_OSX)
+ pthread_setname_np(name);
+#else
+ // Prevent warnings for unused parameters…
+ (void)name;
+#endif
+}
+
+std::string thread_util::GetProcessName()
+{
+#if !defined(CAN_READ_PROCESS_NAME)
+ return «»;
+#endif
+
+ char threadname_buff[16];
+ char* pthreadname_buff = (char*)(&threadname_buff);

I don’t think you need this variable; using `threadname_buff` will automatically decay to `(char *)`.

Запись редактировалась последний раз: May 7, 2018, 5:37 pm