summaryrefslogtreecommitdiff
path: root/drivers/unix/thread_posix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/unix/thread_posix.cpp')
-rw-r--r--drivers/unix/thread_posix.cpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp
index bd33c81298..6ace64a923 100644
--- a/drivers/unix/thread_posix.cpp
+++ b/drivers/unix/thread_posix.cpp
@@ -81,9 +81,9 @@ void ThreadPosix::wait_to_finish_func_posix(Thread* p_thread) {
tp->pthread=0;
}
-Error ThreadPosix::set_name(const String& p_name) {
+Error ThreadPosix::set_name_func_posix(const String& p_name) {
- ERR_FAIL_COND_V(pthread == 0, ERR_UNCONFIGURED);
+ pthread_t running_thread = pthread_self();
#ifdef PTHREAD_NO_RENAME
return ERR_UNAVAILABLE;
@@ -93,22 +93,15 @@ Error ThreadPosix::set_name(const String& p_name) {
#ifdef PTHREAD_RENAME_SELF
// check if thread is the same as caller
- int caller = Thread::get_caller_ID();
- int self = get_ID();
- if (caller != self) {
- ERR_EXPLAIN("On this platform, thread can only be renamed with calls from the threads to be renamed.");
- ERR_FAIL_V(ERR_UNAVAILABLE);
- return ERR_UNAVAILABLE;
- };
int err = pthread_setname_np(p_name.utf8().get_data());
#else
#ifdef PTHREAD_BSD_SET_NAME
- pthread_set_name_np(pthread, p_name.utf8().get_data());
+ pthread_set_name_np(running_thread, p_name.utf8().get_data());
int err = 0; // Open/FreeBSD ignore errors in this function
#else
- int err = pthread_setname_np(pthread, p_name.utf8().get_data());
+ int err = pthread_setname_np(running_thread, p_name.utf8().get_data());
#endif // PTHREAD_BSD_SET_NAME
#endif // PTHREAD_RENAME_SELF
@@ -123,7 +116,7 @@ void ThreadPosix::make_default() {
create_func=create_func_posix;
get_thread_ID_func=get_thread_ID_func_posix;
wait_to_finish_func=wait_to_finish_func_posix;
-
+ set_name_func = set_name_func_posix;
}
ThreadPosix::ThreadPosix() {