Author: stefan2
Date: Sat Jul 2 00:31:15 2011
New Revision: 1142131
URL: http://svn.apache.org/viewvc?rev=1142131&view=rev
Log:
Replace usage of plain APR thread mutex API with the new svn_mutex
API in DSO.
* subversion/libsvn_subr/dso.c
(dso_mutex): switch to svn_mutex__t
(svn_dso_initialize2, svn_dso_load): switch to svn_mutex API
Modified:
subversion/branches/svn_mutex/subversion/libsvn_subr/dso.c
Modified: subversion/branches/svn_mutex/subversion/libsvn_subr/dso.c
URL:
http://svn.apache.org/viewvc/subversion/branches/svn_mutex/subversion/libsvn_subr/dso.c?rev=1142131&r1=1142130&r2=1142131&view=diff
==============================================================================
--- subversion/branches/svn_mutex/subversion/libsvn_subr/dso.c (original)
+++ subversion/branches/svn_mutex/subversion/libsvn_subr/dso.c Sat Jul 2
00:31:15 2011
@@ -26,10 +26,10 @@
#include "svn_pools.h"
#include "svn_private_config.h"
+#include "private/svn_mutex.h"
+
/* A mutex to protect our global pool and cache. */
-#if APR_HAS_THREADS
-static apr_thread_mutex_t *dso_mutex;
-#endif
+static svn_mutex__t dso_mutex;
/* Global pool to allocate DSOs in. */
static apr_pool_t *dso_pool;
@@ -49,20 +49,12 @@ static int not_there_sentinel;
svn_error_t *
svn_dso_initialize2(void)
{
-#if APR_HAS_THREADS
- apr_status_t status;
-#endif
if (dso_pool)
return SVN_NO_ERROR;
dso_pool = svn_pool_create(NULL);
-#if APR_HAS_THREADS
- status = apr_thread_mutex_create(&dso_mutex,
- APR_THREAD_MUTEX_DEFAULT, dso_pool);
- if (status)
- return svn_error_wrap_apr(status, _("Can't create DSO mutex"));
-#endif
+ SVN_ERR(svn_mutex__init(&dso_mutex, TRUE, dso_pool));
dso_cache = apr_hash_make(dso_pool);
return SVN_NO_ERROR;
@@ -72,16 +64,10 @@ svn_dso_initialize2(void)
svn_error_t *
svn_dso_load(apr_dso_handle_t **dso, const char *fname)
{
- apr_status_t status;
-
if (! dso_pool)
SVN_ERR(svn_dso_initialize2());
-#if APR_HAS_THREADS
- status = apr_thread_mutex_lock(dso_mutex);
- if (status)
- return svn_error_wrap_apr(status, _("Can't grab DSO mutex"));
-#endif
+ SVN_ERR(svn_mutex__lock(dso_mutex));
*dso = apr_hash_get(dso_cache, fname, APR_HASH_KEY_STRING);
@@ -91,18 +77,13 @@ svn_dso_load(apr_dso_handle_t **dso, con
if (*dso == NOT_THERE)
{
*dso = NULL;
-#if APR_HAS_THREADS
- status = apr_thread_mutex_unlock(dso_mutex);
- if (status)
- return svn_error_wrap_apr(status, _("Can't ungrab DSO mutex"));
-#endif
- return SVN_NO_ERROR;
+ return svn_mutex__unlock(dso_mutex, SVN_NO_ERROR);
}
/* If we got nothing back from the cache, try and load the library. */
if (! *dso)
{
- status = apr_dso_load(dso, fname, dso_pool);
+ apr_status_t status = apr_dso_load(dso, fname, dso_pool);
if (status)
{
#ifdef SVN_DEBUG
@@ -117,12 +98,7 @@ svn_dso_load(apr_dso_handle_t **dso, con
APR_HASH_KEY_STRING,
NOT_THERE);
-#if APR_HAS_THREADS
- status = apr_thread_mutex_unlock(dso_mutex);
- if (status)
- return svn_error_wrap_apr(status, _("Can't ungrab DSO mutex"));
-#endif
- return SVN_NO_ERROR;
+ return svn_mutex__unlock(dso_mutex, SVN_NO_ERROR);
}
/* Stash the dso so we can use it next time. */
@@ -132,12 +108,6 @@ svn_dso_load(apr_dso_handle_t **dso, con
*dso);
}
-#if APR_HAS_THREADS
- status = apr_thread_mutex_unlock(dso_mutex);
- if (status)
- return svn_error_wrap_apr(status, _("Can't ungrab DSO mutex"));
-#endif
-
- return SVN_NO_ERROR;
+ return svn_mutex__unlock(dso_mutex, SVN_NO_ERROR);
}
#endif /* APR_HAS_DSO */