FreeBSD/contrib/subversion/subversion/libsvn_subr/cache-membuffer.c
/* If locking is supported for CACHE, acquire a write lock for it.
 * Set *SUCCESS to FALSE, if we couldn't acquire the write lock;
 * leave it untouched otherwise.
 */
If locking is supported for CACHE, acquire a write lock for it.
Set *SUCCESS to FALSE, if we couldn't acquire the write lock;
leave it untouched otherwise.
If locking is supported for CACHE acquire a write lock for it . Set * SUCCESS to FALSE if we couldn ' t acquire the write lock ; leave it untouched otherwise .
static svn_error_t *
write_lock_cache(svn_membuffer_t *cache, svn_boolean_t *success)
{
#if (APR_HAS_THREADS && USE_SIMPLE_MUTEX)
  return svn_mutex__lock(cache->lock);
#elif (APR_HAS_THREADS && !USE_SIMPLE_MUTEX)
  if (cache->lock)
    {
      apr_status_t status;
      if (cache->allow_blocking_writes)
        {
          status = apr_thread_rwlock_wrlock(cache->lock);
        }
      else
        {
          status = apr_thread_rwlock_trywrlock(cache->lock);
          if (SVN_LOCK_IS_BUSY(status))
            {
              *success = FALSE;
              status = APR_SUCCESS;
            }
        }
      if (status)
        return svn_error_wrap_apr(status,
                                  _("Can't write-lock cache mutex"));
    }
  return SVN_NO_ERROR;
#else
  return SVN_NO_ERROR;
#endif
}
static svn_error_t * write_lock_cache ( svn_membuffer_t * cache , svn_boolean_t * success ) { #if ( APR_HAS_THREADS && USE_SIMPLE_MUTEX ) return svn_mutex__lock ( cache -> lock ) ; #elif ( APR_HAS_THREADS && ! USE_SIMPLE_MUTEX ) if ( cache -> lock ) { apr_status_t status ; if ( cache -> allow_blocking_writes ) { status = apr_thread_rwlock_wrlock ( cache -> lock ) ; } else { status = apr_thread_rwlock_trywrlock ( cache -> lock ) ; if ( SVN_LOCK_IS_BUSY ( status ) ) { * success = FALSE ; status = APR_SUCCESS ; } } if ( status ) return svn_error_wrap_apr ( status , _ ( " " ) ) ; } return SVN_NO_ERROR ; #else return SVN_NO_ERROR ; #endif }
If locking is supported for CACHE, acquire a write lock for it.
If locking is supported for CACHE acquire a write lock for it .