mirror of
https://github.com/LizardByte/Sunshine.git
synced 2026-12-04 14:21:58 +09:00
fix(linux/freebsd): truncate thread names to 15 characters (#5527)
This commit is contained in:
1 parent
6ad5f9735d
commit
9e1f089e1f
4 files changed
+10
-7
No files matched your search
@@ -949,7 +949,7 @@ namespace platf {
|
||||
*
|
||||
* @param name Human-readable name to assign.
|
||||
*/
|
||||
void set_thread_name(const std::string &name);
|
||||
void set_thread_name(std::string_view name);
|
||||
|
||||
void enable_mouse_keys();
|
||||
|
||||
|
||||
@@ -521,8 +521,10 @@ namespace platf {
|
||||
}
|
||||
}
|
||||
|
||||
void set_thread_name(const std::string &name) {
|
||||
pthread_setname_np(pthread_self(), name.c_str());
|
||||
void set_thread_name(std::string_view name) {
|
||||
// Truncate name to fit in Linux/FreeBSD kernel's 16 byte limit
|
||||
std::string tr_name {name.substr(0, 15)};
|
||||
pthread_setname_np(pthread_self(), tr_name.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -252,8 +252,9 @@ namespace platf {
|
||||
pthread_set_qos_class_self_np(mac_priority, 0);
|
||||
}
|
||||
|
||||
void set_thread_name(const std::string &name) {
|
||||
pthread_setname_np(name.c_str());
|
||||
void set_thread_name(std::string_view name) {
|
||||
std::string thread_name {name};
|
||||
pthread_setname_np(thread_name.c_str());
|
||||
}
|
||||
|
||||
void enable_mouse_keys() {
|
||||
|
||||
@@ -1130,8 +1130,8 @@ namespace platf {
|
||||
}
|
||||
}
|
||||
|
||||
void set_thread_name(const std::string &name) {
|
||||
std::wstring wname = utf_utils::from_utf8(name);
|
||||
void set_thread_name(std::string_view name) {
|
||||
std::wstring wname = utf_utils::from_utf8(std::string {name});
|
||||
HRESULT hr = SetThreadDescription(GetCurrentThread(), wname.c_str());
|
||||
if (FAILED(hr)) {
|
||||
BOOST_LOG(error) << "SetThreadDescription failed: " << hr;
|
||||
|
||||
Reference in new issue
Block a user