Commit debc9d47 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

rwlock: cancellation safety

parent fba184a0
......@@ -60,7 +60,9 @@ void vlc_rwlock_rdlock (vlc_rwlock_t *lock)
while (lock->state < 0)
{
assert (lock->state == WRITER_BIT);
mutex_cleanup_push (&lock->mutex);
vlc_cond_wait (&lock->wait, &lock->mutex);
vlc_cleanup_pop ();
}
if (unlikely(lock->state >= READER_MASK))
abort (); /* An overflow is certainly a recursion bug. */
......@@ -73,7 +75,11 @@ void vlc_rwlock_wrlock (vlc_rwlock_t *lock)
vlc_mutex_lock (&lock->mutex);
/* Wait until nobody owns the lock in any way. */
while (lock->state != 0)
{
mutex_cleanup_push (&lock->mutex);
vlc_cond_wait (&lock->wait, &lock->mutex);
vlc_cleanup_pop ();
}
lock->state = WRITER_BIT;
vlc_mutex_unlock (&lock->mutex);
}
......
......@@ -558,6 +558,7 @@ void vlc_rwlock_destroy (vlc_rwlock_t *lock)
/**
* Acquires a read/write lock for reading. Recursion is allowed.
* @note This function may be a point of cancellation.
*/
void vlc_rwlock_rdlock (vlc_rwlock_t *lock)
{
......@@ -567,6 +568,7 @@ void vlc_rwlock_rdlock (vlc_rwlock_t *lock)
/**
* Acquires a read/write lock for writing. Recursion is not allowed.
* @note This function may be a point of cancellation.
*/
void vlc_rwlock_wrlock (vlc_rwlock_t *lock)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment