From afae448ff28f64a0126339f8847db839eda4dabf Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Fri, 11 Nov 2022 06:59:02 -0500 Subject: [PATCH] posix: pthread: take care with pthread cond resources Previously, `pthread_cond_init()` could not actually fail, and destroying condition variables was a no-op, and it was missing in `pthread_exit()`. However, with the change of `pthread_cond_t` to `uint32_t`, and since those are embedded inside of `struct posix_thread` for the time being, the pthread code needs to keep track that it is relinquishes used condition variables when a thread completes. Signed-off-by: Chris Friedt --- lib/posix/pthread.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/posix/pthread.c b/lib/posix/pthread.c index 42961bd233..21ba0ef688 100644 --- a/lib/posix/pthread.c +++ b/lib/posix/pthread.c @@ -407,6 +407,8 @@ void pthread_exit(void *retval) pthread_mutex_unlock(&self->state_lock); pthread_mutex_destroy(&self->state_lock); + pthread_cond_destroy(&self->state_cond); + k_thread_abort((k_tid_t)self); }