examples/ostest: pthread rwlock cleanup handlers must call pthread_consistent, not pthread_mutex_unlock() on cancellation if robust mutexes are enabled.

This commit is contained in:
Gregory Nutt 2017-04-10 08:44:08 -06:00
parent b51b72b2db
commit 84849cfc5e
2 changed files with 25 additions and 2 deletions

View File

@ -55,7 +55,18 @@ static void rdlock_cleanup(FAR void *arg)
{
FAR pthread_rwlock_t *rw_lock = (FAR pthread_rwlock_t *)arg;
pthread_mutex_unlock(&rw_lock->lock);
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
/* Check if this is a robust mutex in an inconsistent state */
if ((rw_lock->lock.flags & _PTHREAD_MFLAGS_INCONSISTENT) != 0)
{
(void)pthread_mutex_consistent(&rw_lock->lock);
}
else
#endif
{
(void)pthread_mutex_unlock(&rw_lock->lock);
}
}
#endif

View File

@ -56,7 +56,19 @@ static void wrlock_cleanup(FAR void *arg)
FAR pthread_rwlock_t *rw_lock = (FAR pthread_rwlock_t *)arg;
rw_lock->num_writers--;
pthread_mutex_unlock(&rw_lock->lock);
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
/* Check if this is a robust mutex in an inconsistent state */
if ((rw_lock->lock.flags & _PTHREAD_MFLAGS_INCONSISTENT) != 0)
{
(void)pthread_mutex_consistent(&rw_lock->lock);
}
else
#endif
{
(void)pthread_mutex_unlock(&rw_lock->lock);
}
}
#endif