You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2011/10/15 11:03:08 UTC
svn commit: r1183603 - in /subversion/trunk/subversion:
include/private/svn_mutex.h libsvn_fs/fs-loader.c libsvn_fs_base/bdb/env.c
libsvn_subr/dso.c libsvn_subr/svn_mutex.c tests/libsvn_subr/cache-test.c
Author: stefan2
Date: Sat Oct 15 09:03:08 2011
New Revision: 1183603
URL: http://svn.apache.org/viewvc?rev=1183603&view=rev
Log:
Slightly changing the semantics of svn_mutex__init(). If the
enable_mutex parameter has been set, the function will try
to enable the the mutex only if SVN is potentially multi-threaded,
i.e. if APR_HAS_THREADS is set.
Thus, the parameter can simply be set to TRUE, if we would
need synchronization in a multi-threaded environment.
* subversion/libsvn_subr/svn_mutex.c
(svn_mutex__init): no-op if APR_HAS_THREADS isn't set
* subversion/include/private/svn_mutex.h
(svn_mutex__init): update docstring
* subversion/libsvn_subr/dso.c
(svn_dso_initialize2): adapt caller
* subversion/libsvn_fs_base/bdb/env.c
(bdb_init_cb): ditto
* subversion/libsvn_fs/fs-loader.c
(svn_fs_initialize): ditto
* subversion/tests/libsvn_subr/cache-test.c
(test_inprocess_cache_basic): adapt indirect caller
(test_membuffer_cache_basic): ditto
Modified:
subversion/trunk/subversion/include/private/svn_mutex.h
subversion/trunk/subversion/libsvn_fs/fs-loader.c
subversion/trunk/subversion/libsvn_fs_base/bdb/env.c
subversion/trunk/subversion/libsvn_subr/dso.c
subversion/trunk/subversion/libsvn_subr/svn_mutex.c
subversion/trunk/subversion/tests/libsvn_subr/cache-test.c
Modified: subversion/trunk/subversion/include/private/svn_mutex.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_mutex.h?rev=1183603&r1=1183602&r2=1183603&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_mutex.h (original)
+++ subversion/trunk/subversion/include/private/svn_mutex.h Sat Oct 15 09:03:08 2011
@@ -60,8 +60,7 @@ typedef void svn_mutex__t;
* the pointer will be set to @c NULL and @ref svn_mutex__lock as well as
* @ref svn_mutex__unlock will be no-ops.
*
- * If @a enable_mutex is set but threading is not supported by APR, this
- * function returns an @c APR_ENOTIMPL error.
+ * If threading is not supported by APR, this function is a no-op.
*/
svn_error_t *
svn_mutex__init(svn_mutex__t **mutex,
Modified: subversion/trunk/subversion/libsvn_fs/fs-loader.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs/fs-loader.c?rev=1183603&r1=1183602&r2=1183603&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs/fs-loader.c (original)
+++ subversion/trunk/subversion/libsvn_fs/fs-loader.c Sat Oct 15 09:03:08 2011
@@ -265,7 +265,7 @@ svn_fs_initialize(apr_pool_t *pool)
return SVN_NO_ERROR;
common_pool = svn_pool_create(pool);
- SVN_ERR(svn_mutex__init(&common_pool_lock, APR_HAS_THREADS, common_pool));
+ SVN_ERR(svn_mutex__init(&common_pool_lock, TRUE, common_pool));
/* ### This won't work if POOL is NULL and libsvn_fs is loaded as a DSO
### (via libsvn_ra_local say) since the global common_pool will live
Modified: subversion/trunk/subversion/libsvn_fs_base/bdb/env.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_base/bdb/env.c?rev=1183603&r1=1183602&r2=1183603&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_base/bdb/env.c (original)
+++ subversion/trunk/subversion/libsvn_fs_base/bdb/env.c Sat Oct 15 09:03:08 2011
@@ -379,7 +379,7 @@ bdb_init_cb(void *baton, apr_pool_t *poo
bdb_cache_pool = svn_pool_create(pool);
bdb_cache = apr_hash_make(bdb_cache_pool);
- SVN_ERR(svn_mutex__init(&bdb_cache_lock, APR_HAS_THREADS, bdb_cache_pool));
+ SVN_ERR(svn_mutex__init(&bdb_cache_lock, TRUE, bdb_cache_pool));
apr_pool_cleanup_register(bdb_cache_pool, NULL, clear_cache,
apr_pool_cleanup_null);
Modified: subversion/trunk/subversion/libsvn_subr/dso.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/dso.c?rev=1183603&r1=1183602&r2=1183603&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/dso.c (original)
+++ subversion/trunk/subversion/libsvn_subr/dso.c Sat Oct 15 09:03:08 2011
@@ -54,7 +54,7 @@ svn_dso_initialize2(void)
dso_pool = svn_pool_create(NULL);
- SVN_ERR(svn_mutex__init(&dso_mutex, APR_HAS_THREADS, dso_pool));
+ SVN_ERR(svn_mutex__init(&dso_mutex, TRUE, dso_pool));
dso_cache = apr_hash_make(dso_pool);
return SVN_NO_ERROR;
Modified: subversion/trunk/subversion/libsvn_subr/svn_mutex.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/svn_mutex.c?rev=1183603&r1=1183602&r2=1183603&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/svn_mutex.c (original)
+++ subversion/trunk/subversion/libsvn_subr/svn_mutex.c Sat Oct 15 09:03:08 2011
@@ -43,10 +43,6 @@ svn_mutex__init(svn_mutex__t **mutex_p,
*mutex_p = apr_mutex;
}
-#else
- if (enable_mutex)
- return svn_error_wrap_apr(SVN_ERR_UNSUPPORTED_FEATURE,
- _("APR doesn't support threads"));
#endif
return SVN_NO_ERROR;
Modified: subversion/trunk/subversion/tests/libsvn_subr/cache-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/cache-test.c?rev=1183603&r1=1183602&r2=1183603&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/cache-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/cache-test.c Sat Oct 15 09:03:08 2011
@@ -135,7 +135,7 @@ test_inprocess_cache_basic(apr_pool_t *p
APR_HASH_KEY_STRING,
1,
1,
- APR_HAS_THREADS,
+ TRUE,
"",
pool));
@@ -184,7 +184,7 @@ test_membuffer_cache_basic(apr_pool_t *p
svn_membuffer_t *membuffer;
SVN_ERR(svn_cache__membuffer_cache_create(&membuffer, 10*1024, 1,
- APR_HAS_THREADS, pool));
+ TRUE, pool));
/* Create a cache with just one entry. */
SVN_ERR(svn_cache__create_membuffer_cache(&cache,
Re: svn commit: r1183603 - in /subversion/trunk/subversion:
include/private/svn_mutex.h libsvn_fs/fs-loader.c libsvn_fs_base/bdb/env.c
libsvn_subr/dso.c libsvn_subr/svn_mutex.c tests/libsvn_subr/cache-test.c
Posted by Stefan Sperling <st...@elego.de>.
On Sat, Oct 15, 2011 at 09:03:08AM -0000, stefan2@apache.org wrote:
> Author: stefan2
> Date: Sat Oct 15 09:03:08 2011
> New Revision: 1183603
>
> URL: http://svn.apache.org/viewvc?rev=1183603&view=rev
> Log:
> Slightly changing the semantics of svn_mutex__init(). If the
> enable_mutex parameter has been set, the function will try
> to enable the the mutex only if SVN is potentially multi-threaded,
> i.e. if APR_HAS_THREADS is set.
>
> Thus, the parameter can simply be set to TRUE, if we would
> need synchronization in a multi-threaded environment.
Quoting a bit of the code:
svn_mutex__init(svn_mutex__t **mutex_p,
svn_boolean_t enable_mutex,
apr_pool_t *result_pool)
{
#if APR_HAS_THREADS
*mutex_p = NULL;
if (enable_mutex)
{
[...]
*mutex_p not initialised if APR doesn't have threads.
Is this safe?
It seems odd to have a function that says "I will init mutexes"
with a parameter that says "don't init mutexes".
Can't we just set a mutex pointer to NULL instead of calling
svn_mutex__init() with enable_mutex == FALSE, and remove the
enable_mutex parameter?