From cfc71db80c3baac5fe76db1bdcf0c266391eba9e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 10 Apr 2017 09:51:44 -0600 Subject: [PATCH] pthreads: Backed most of last pthread changes. Found the 'real' root poblem. A one like error in pthread_mutex.c. --- examples/ostest/pthread_cleanup.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/ostest/pthread_cleanup.c b/examples/ostest/pthread_cleanup.c index b6f018c05..54650823f 100644 --- a/examples/ostest/pthread_cleanup.c +++ b/examples/ostest/pthread_cleanup.c @@ -60,21 +60,20 @@ static void cleanup(FAR void * data) FAR struct sync_s *sync = (FAR struct sync_s *) data; int status; -#ifdef CONFIG_PTHREAD_MUTEX_UNSAFE + /* Note: pthread_cond_wait() will release the mutex while it waits on + * condition value. So a EPERM error is not a failure. + */ + status = pthread_mutex_unlock(&sync->lock); - if (status != 0) + if (status == EPERM) + { + printf("pthread_cleanup: thread did not have mutex locked: %d\n", status); + } + else if (status != 0) { printf("pthread_cleanup: ERROR pthread_mutex_unlock in cleanup handler. " "Status: %d\n", status); } -#else - status = pthread_mutex_consistent(&sync->lock); - if (status != 0) - { - printf("pthread_cleanup: ERROR pthread_mutex_consistent in cleanup handler. " - "Status: %d\n", status); - } -#endif } static void *cleanup_thread(FAR void * data)