-
Notifications
You must be signed in to change notification settings - Fork 54
proxy: Name threads spawned by the event loop #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,10 @@ | |
| #include <pthread_np.h> | ||
| #endif // HAVE_PTHREAD_GETTHREADID_NP | ||
|
|
||
| #if __has_include(<sys/prctl.h>) | ||
| #include <sys/prctl.h> | ||
| #endif | ||
|
|
||
| extern "C" char **environ; // NOLINT(readability-redundant-declaration) | ||
|
|
||
| namespace mp { | ||
|
|
@@ -74,6 +78,22 @@ template <std::size_t N> | |
|
|
||
| } // namespace | ||
|
|
||
| // Copied from https://github.com/bitcoin/bitcoin/blob/d3e40af2597/src/util/threadnames.cpp#L21-L36 | ||
| void SetOsThreadName(const char* name) | ||
| { | ||
| #if defined(PR_SET_NAME) | ||
| // Only the first 15 characters are used (16 - NUL terminator) | ||
| ::prctl(PR_SET_NAME, name, 0, 0, 0); | ||
| #elif defined(HAVE_PTHREAD_GETTHREADID_NP) | ||
| pthread_set_name_np(pthread_self(), name); | ||
| #elif defined(__APPLE__) | ||
| pthread_setname_np(name); | ||
| #else | ||
| // Prevent warnings for unused parameters... | ||
| (void)name; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In commit "proxy: Name threads spawned by the event loop" (61b6cd2) Note for followup probably will want to extend this to windows.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, for Bitcoin Core it would be useful too.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened for bitcoin core: bitcoin/bitcoin#35884 |
||
| #endif | ||
| } | ||
|
|
||
| std::string ThreadName(const char* exe_name) | ||
| { | ||
| char thread_name[16] = {0}; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.