Skip to content

Commit

Permalink
posix: pthread: Move logging out of spinlock area
Browse files Browse the repository at this point in the history
Move LOG_ERR() outside of K_SPINLOCK().

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
  • Loading branch information
finikorg authored and fabiobaltieri committed Oct 3, 2023
1 parent 3d82fbe commit 0ee0380
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/posix/pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,14 +667,12 @@ int pthread_join(pthread_t pthread, void **status)
{
if (t->detachstate != PTHREAD_CREATE_JOINABLE) {
ret = EINVAL;
LOG_ERR("Pthread %p is not a joinable", &t->thread);
K_SPINLOCK_BREAK;
}

if (t->qid == POSIX_THREAD_READY_Q) {
/* in case thread has moved to ready_q between to_posix_thread() and here */
ret = ESRCH;
LOG_ERR("Pthread %p has already been joined", &t->thread);
K_SPINLOCK_BREAK;
}

Expand All @@ -685,8 +683,15 @@ int pthread_join(pthread_t pthread, void **status)
t->detachstate = PTHREAD_CREATE_DETACHED;
}

if (ret != 0) {
switch (ret) {
case ESRCH:
LOG_ERR("Pthread %p has already been joined", &t->thread);
return ret;
case EINVAL:
LOG_ERR("Pthread %p is not a joinable", &t->thread);
return ret;
case 0:
break;
}

err = k_thread_join(&t->thread, K_FOREVER);
Expand Down

0 comments on commit 0ee0380

Please sign in to comment.