fix: on join check if the thread is not waiting the current thread

This commit is contained in:
Martin Eyben 2025-03-24 15:21:14 +01:00
parent bf8e6e9d0d
commit 25d2e181e1

View File

@ -140,7 +140,7 @@ int thread_join(thread_t thread, void** retval)
TRACE("Join thread %p", thread);
struct context_entry* entry = thread;
// Check if the target is not already waited by another
if (IS_WAITED(entry) || IS_WAITING(entry) && GET_WAITING_THREAD(entry) != running) {
if (IS_WAITED(entry) || IS_WAITING(entry) && GET_WAITING_THREAD(entry) == running) {
return -1;
}
@ -165,7 +165,7 @@ int thread_join(thread_t thread, void** retval)
*retval = entry->retvalue;
// Clean up
TRACE("DEBUG %p,%d", entry, WAS_ALLOCATED(entry));
DBG("(entry, was_alloacted) : %p,%d", entry, WAS_ALLOCATED(entry));
if (WAS_ALLOCATED(entry)) {
VALGRIND_STACK_DEREGISTER(entry->valgrind_id);
}