* is locked by a writer the current thread will block until the other
* thread has issued silc_rwlock_unlock for the `rwlock'. This function
* may be called multiple times to acquire the read lock. There must be
- * same amount of silc_rwlock_unlock calls. If `rwlock' is NULL this
+ * same number of silc_rwlock_unlock calls. If `rwlock' is NULL this
* function has no effect.
*
***/
* Acquires write lock of the read/write lock `rwlock'. If the `rwlock'
* is locked by a writer or a reader the current thread will block until
* the other thread(s) have issued silc_rwlock_unlock for the `rwlock'.
- * If `rwlock' is NULL this function has no effect.
+ * A thread may acquire the write lock only once. A deadlock may occur
+ * if thread attempts to acquire the write lock when it has already done
+ * so. If `rwlock' is NULL this function has no effect.
*
***/
void silc_rwlock_wrlock(SilcRwLock rwlock);
{
#ifdef SILC_THREADS
if (mutex) {
- if (pthread_mutex_lock(&mutex->mutex))
- SILC_ASSERT(FALSE);
+ SILC_VERIFY(pthread_mutex_lock(&mutex->mutex) == 0);
mutex->locked = TRUE;
}
#endif /* SILC_THREADS */
{
#ifdef SILC_THREADS
if (mutex) {
- if (pthread_mutex_unlock(&mutex->mutex))
- SILC_ASSERT(FALSE);
+ SILC_VERIFY(pthread_mutex_unlock(&mutex->mutex) == 0);
mutex->locked = FALSE;
}
#endif /* SILC_THREADS */
{
#ifdef SILC_THREADS
if (mutex)
- SILC_ASSERT(mutex->locked);
+ SILC_VERIFY(mutex->locked);
#endif /* SILC_THREADS */
}
{
#ifdef SILC_THREADS
if (rwlock)
- pthread_rwlock_wrlock(&rwlock->rwlock);
+ SILC_VERIFY(pthread_rwlock_wrlock(&rwlock->rwlock) == 0);
#endif /* SILC_THREADS */
}
{
#ifdef SILC_THREADS
if (rwlock)
- pthread_rwlock_unlock(&rwlock->rwlock);
+ SILC_VERIFY(pthread_rwlock_unlock(&rwlock->rwlock) == 0);
#endif /* SILC_THREADS */
}