[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1142130 - in /subversion/branches/svn_mutex/subversion/libsvn_fs_fs: fs.c fs.h fs_fs.c

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Tue, 5 Jul 2011 00:51:51 +0300

stefan2_at_apache.org wrote on Sat, Jul 02, 2011 at 00:27:28 -0000:
> Author: stefan2
> Date: Sat Jul 2 00:27:28 2011
> New Revision: 1142130
>
> URL: http://svn.apache.org/viewvc?rev=1142130&view=rev
> Log:
> Replace usage of plain APR thread mutex API with the new svn_mutex
> API in FSFS.
>
> * subversion/libsvn_fs_fs/fs.h
> (fs_fs_shared_data_t): use svn_mutex instead of plain apr mutexes
> * subversion/libsvn_fs_fs/fs_fs.c
> (with_txnlist_lock, with_some_lock, svn_fs_fs__with_write_lock,
> with_txn_current_lock): switch to svn_mutex API
> * subversion/libsvn_fs_fs/fs.c
> (fs_serialized_init): dito
>
> Modified:
> subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.c
> subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.h
> subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs_fs.c
>
> Modified: subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.c
> URL: http://svn.apache.org/viewvc/subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.c?rev=1142130&r1=1142129&r2=1142130&view=diff
> ==============================================================================
> --- subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.c (original)
> +++ subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.c Sat Jul 2 00:27:28 2011
> @@ -89,29 +89,12 @@ fs_serialized_init(svn_fs_t *fs, apr_poo
> /* POSIX fcntl locks are per-process, so we need a mutex for
> intra-process synchronization when grabbing the repository write
> lock. */
> - status = apr_thread_mutex_create(&ffsd->fs_write_lock,
> - APR_THREAD_MUTEX_DEFAULT, common_pool);
> - if (status)
> - return svn_error_wrap_apr(status,
> - _("Can't create FSFS write-lock mutex"));
> + SVN_ERR(svn_mutex__init(&ffsd->fs_write_lock, TRUE, common_pool));
>
> /* ... not to mention locking the txn-current file. */
> - status = apr_thread_mutex_create(&ffsd->txn_current_lock,
> - APR_THREAD_MUTEX_DEFAULT, common_pool);
> - if (status)
> - return svn_error_wrap_apr(status,
> - _("Can't create FSFS txn-current mutex"));
> + SVN_ERR(svn_mutex__init(&ffsd->txn_current_lock, TRUE, common_pool));
> #endif
> -#if APR_HAS_THREADS
> - /* We also need a mutex for synchronising access to the active
> - transaction list and free transaction pointer. */
> - status = apr_thread_mutex_create(&ffsd->txn_list_lock,
> - APR_THREAD_MUTEX_DEFAULT, common_pool);
> - if (status)
> - return svn_error_wrap_apr(status,
> - _("Can't create FSFS txn list mutex"));
> -#endif
> -
> + SVN_ERR(svn_mutex__init(&ffsd->txn_list_lock, TRUE, common_pool));
>

#ifdef SVN_FS_FS__USE_LOCK_MUTEX
      SVN_ERR(svn_mutex__init(&ffsd->txn_list_lock, TRUE, common_pool));
#else
      SVN_ERR(svn_mutex__init(&ffsd->txn_list_lock, FALSE, common_pool));
#endif

?

> key = apr_pstrdup(common_pool, key);
> status = apr_pool_userdata_set(ffsd, key, NULL, common_pool);
>
> Modified: subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.h
> URL: http://svn.apache.org/viewvc/subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.h?rev=1142130&r1=1142129&r2=1142130&view=diff
> ==============================================================================
> --- subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.h (original)
> +++ subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.h Sat Jul 2 00:27:28 2011
> @@ -34,6 +34,7 @@
> #include "private/svn_cache.h"
> #include "private/svn_fs_private.h"
> #include "private/svn_sqlite.h"
> +#include "private/svn_mutex.h"
>
> #ifdef __cplusplus
> extern "C" {
> @@ -182,18 +183,16 @@ typedef struct fs_fs_shared_data_t
> Access to this object is synchronised under TXN_LIST_LOCK. */
> fs_fs_shared_txn_data_t *free_txn;
>
> -#if APR_HAS_THREADS
> /* A lock for intra-process synchronization when accessing the TXNS list. */
> - apr_thread_mutex_t *txn_list_lock;
> -#endif
> + svn_mutex__t txn_list_lock;
> #if SVN_FS_FS__USE_LOCK_MUTEX
> /* A lock for intra-process synchronization when grabbing the
> repository write lock. */
> - apr_thread_mutex_t *fs_write_lock;
> + svn_mutex__t fs_write_lock;
>
> /* A lock for intra-process synchronization when locking the
> txn-current file. */
> - apr_thread_mutex_t *txn_current_lock;
> + svn_mutex__t txn_current_lock;
> #endif
>
> /* The common pool, under which this object is allocated, subpools
>
> Modified: subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs_fs.c
> URL: http://svn.apache.org/viewvc/subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs_fs.c?rev=1142130&r1=1142129&r2=1142130&view=diff
> ==============================================================================
> --- subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs_fs.c (original)
> +++ subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs_fs.c Sat Jul 2 00:27:28 2011
> @@ -511,25 +511,14 @@ with_txnlist_lock(svn_fs_t *fs,
> apr_pool_t *pool)
> {
> svn_error_t *err;
> -#if APR_HAS_THREADS
> fs_fs_data_t *ffd = fs->fsap_data;
> fs_fs_shared_data_t *ffsd = ffd->shared;
> - apr_status_t apr_err;
>
> - apr_err = apr_thread_mutex_lock(ffsd->txn_list_lock);
> - if (apr_err)
> - return svn_error_wrap_apr(apr_err, _("Can't grab FSFS txn list mutex"));
> -#endif
> + SVN_ERR(svn_mutex__lock(ffsd->txn_list_lock));
>
> err = body(fs, baton, pool);
>
> -#if APR_HAS_THREADS
> - apr_err = apr_thread_mutex_unlock(ffsd->txn_list_lock);
> - if (apr_err && !err)
> - return svn_error_wrap_apr(apr_err, _("Can't ungrab FSFS txn list mutex"));
> -#endif
> -
> - return svn_error_trace(err);
> + return svn_error_trace(svn_mutex__unlock(ffsd->txn_list_lock, err));
> }
>
>
> @@ -565,7 +554,7 @@ with_some_lock(svn_fs_t *fs,
> void *baton,
> const char *lock_filename,
> #if SVN_FS_FS__USE_LOCK_MUTEX
> - apr_thread_mutex_t *lock_mutex,
> + svn_mutex__t lock_mutex,
> #endif
> apr_pool_t *pool)
> {
> @@ -573,15 +562,7 @@ with_some_lock(svn_fs_t *fs,
> svn_error_t *err;
>
> #if SVN_FS_FS__USE_LOCK_MUTEX
> - apr_status_t status;
> -
> - /* POSIX fcntl locks are per-process, so we need to serialize locks
> - within the process. */
> - status = apr_thread_mutex_lock(lock_mutex);
> - if (status)
> - return svn_error_wrap_apr(status,
> - _("Can't grab FSFS mutex for '%s'"),
> - lock_filename);
> + SVN_ERR(svn_mutex__lock(lock_mutex));
> #endif
>
> err = get_lock_on_filesystem(lock_filename, subpool);
> @@ -602,15 +583,7 @@ with_some_lock(svn_fs_t *fs,
>
> svn_pool_destroy(subpool);
>
> -#if SVN_FS_FS__USE_LOCK_MUTEX
> - status = apr_thread_mutex_unlock(lock_mutex);
> - if (status && !err)
> - return svn_error_wrap_apr(status,
> - _("Can't ungrab FSFS mutex for '%s'"),
> - lock_filename);
> -#endif
> -
> - return svn_error_trace(err);
> + return svn_error_trace(svn_mutex__unlock(lock_mutex, err));
> }
>
> svn_error_t *
> @@ -623,13 +596,12 @@ svn_fs_fs__with_write_lock(svn_fs_t *fs,
> #if SVN_FS_FS__USE_LOCK_MUTEX
> fs_fs_data_t *ffd = fs->fsap_data;
> fs_fs_shared_data_t *ffsd = ffd->shared;
> - apr_thread_mutex_t *mutex = ffsd->fs_write_lock;
> #endif
>
> return with_some_lock(fs, body, baton,
> path_lock(fs, pool),
> #if SVN_FS_FS__USE_LOCK_MUTEX
> - mutex,
> + ffsd->fs_write_lock,
> #endif
> pool);
> }
> @@ -646,13 +618,12 @@ with_txn_current_lock(svn_fs_t *fs,
> #if SVN_FS_FS__USE_LOCK_MUTEX
> fs_fs_data_t *ffd = fs->fsap_data;
> fs_fs_shared_data_t *ffsd = ffd->shared;
> - apr_thread_mutex_t *mutex = ffsd->txn_current_lock;
> #endif
>
> return with_some_lock(fs, body, baton,
> path_txn_current_lock(fs, pool),
> #if SVN_FS_FS__USE_LOCK_MUTEX
> - mutex,
> + ffsd->txn_current_lock,
> #endif
> pool);
> }
>
>
Received on 2011-07-04 23:52:50 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.