rename_thread() was broken for the current thread: updating the name is
hardly atomic, so we need to grab the thread lock after all. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12877 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+12
-16
@@ -1615,31 +1615,27 @@ find_thread(const char *name)
|
|||||||
status_t
|
status_t
|
||||||
rename_thread(thread_id id, const char *name)
|
rename_thread(thread_id id, const char *name)
|
||||||
{
|
{
|
||||||
status_t status = B_OK;
|
struct thread *thread = thread_get_current_thread();
|
||||||
struct thread *thread;
|
status_t status = B_BAD_THREAD_ID;
|
||||||
|
cpu_status state;
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
thread = thread_get_current_thread();
|
state = disable_interrupts();
|
||||||
if (thread->id == id) {
|
GRAB_THREAD_LOCK();
|
||||||
// it's ourself, so we know we aren't in the run queue, and we can manipulate
|
|
||||||
// our structure directly
|
|
||||||
strlcpy(thread->name, name, B_OS_NAME_LENGTH);
|
|
||||||
} else {
|
|
||||||
cpu_status state = disable_interrupts();
|
|
||||||
GRAB_THREAD_LOCK();
|
|
||||||
|
|
||||||
|
if (thread->id != id)
|
||||||
thread = thread_get_thread_struct_locked(id);
|
thread = thread_get_thread_struct_locked(id);
|
||||||
if (thread) {
|
|
||||||
strlcpy(thread->name, name, B_OS_NAME_LENGTH);
|
|
||||||
} else
|
|
||||||
status = B_BAD_THREAD_ID;
|
|
||||||
|
|
||||||
RELEASE_THREAD_LOCK();
|
if (thread != NULL) {
|
||||||
restore_interrupts(state);
|
strlcpy(thread->name, name, B_OS_NAME_LENGTH);
|
||||||
|
status = B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RELEASE_THREAD_LOCK();
|
||||||
|
restore_interrupts(state);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user