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:
Axel Dörfler 2005-05-29 00:29:45 +00:00
parent 56c6492868
commit 9620c1d716

View File

@ -1615,30 +1615,26 @@ find_thread(const char *name)
status_t
rename_thread(thread_id id, const char *name)
{
status_t status = B_OK;
struct thread *thread;
struct thread *thread = thread_get_current_thread();
status_t status = B_BAD_THREAD_ID;
cpu_status state;
if (name == NULL)
return B_BAD_VALUE;
thread = thread_get_current_thread();
if (thread->id == id) {
// 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();
state = disable_interrupts();
GRAB_THREAD_LOCK();
if (thread->id != id)
thread = thread_get_thread_struct_locked(id);
if (thread) {
if (thread != NULL) {
strlcpy(thread->name, name, B_OS_NAME_LENGTH);
} else
status = B_BAD_THREAD_ID;
status = B_OK;
}
RELEASE_THREAD_LOCK();
restore_interrupts(state);
}
return status;
}