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/07/11 22:25:28 UTC

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

Author: stefan2
Date: Mon Jul 11 20:25:28 2011
New Revision: 1145330

URL: http://svn.apache.org/viewvc?rev=1145330&view=rev
Log:
On svn_mutex branch:
Switch FS and FSFS loader to the safer SVN_MUTEX__WITH_LOCK macro.
Simplify locking-related code when possible.

* subversion/libsvn_fs_fs/fs.h
  (fs_fs_shared_data_t): we can always have the - maybe dummy -  mutex objects
* subversion/libsvn_fs_fs/fs.c
  (fs_serialized_init): enable mutexes only if required by compile time config
* subversion/libsvn_fs_fs/fs_fs.c
  (with_txnlist_lock): simplify using the macro
  (with_some_lock): rename to with_some_lock_file, defer locking to
  (callersvn_fs_fs__with_write_lock, with_txn_current_lock): adapt callers

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=1145330&r1=1145329&r2=1145330&view=diff
==============================================================================
--- subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.c (original)
+++ subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.c Mon Jul 11 20:25:28 2011
@@ -85,15 +85,16 @@ fs_serialized_init(svn_fs_t *fs, apr_poo
       ffsd = apr_pcalloc(common_pool, sizeof(*ffsd));
       ffsd->common_pool = common_pool;
 
-#if SVN_FS_FS__USE_LOCK_MUTEX
       /* POSIX fcntl locks are per-process, so we need a mutex for
          intra-process synchronization when grabbing the repository write
          lock. */
-      SVN_ERR(svn_mutex__init(&ffsd->fs_write_lock, TRUE, common_pool));
+      SVN_ERR(svn_mutex__init(&ffsd->fs_write_lock,
+                              SVN_FS_FS__USE_LOCK_MUTEX, common_pool));
 
       /* ... not to mention locking the txn-current file. */
-      SVN_ERR(svn_mutex__init(&ffsd->txn_current_lock, TRUE, common_pool));
-#endif
+      SVN_ERR(svn_mutex__init(&ffsd->txn_current_lock, 
+                              SVN_FS_FS__USE_LOCK_MUTEX, common_pool));
+
       SVN_ERR(svn_mutex__init(&ffsd->txn_list_lock, TRUE, common_pool));
 
       key = apr_pstrdup(common_pool, key);

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=1145330&r1=1145329&r2=1145330&view=diff
==============================================================================
--- subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.h (original)
+++ subversion/branches/svn_mutex/subversion/libsvn_fs_fs/fs.h Mon Jul 11 20:25:28 2011
@@ -184,7 +184,7 @@ typedef struct fs_fs_shared_data_t
 
   /* A lock for intra-process synchronization when accessing the TXNS list. */
   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. */
   svn_mutex__t *fs_write_lock;
@@ -192,7 +192,6 @@ typedef struct fs_fs_shared_data_t
   /* A lock for intra-process synchronization when locking the
      txn-current file. */
   svn_mutex__t *txn_current_lock;
-#endif
 
   /* The common pool, under which this object is allocated, subpools
      of which are used to allocate the transaction objects. */

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=1145330&r1=1145329&r2=1145330&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 Mon Jul 11 20:25:28 2011
@@ -510,15 +510,13 @@ with_txnlist_lock(svn_fs_t *fs,
                   const void *baton,
                   apr_pool_t *pool)
 {
-  svn_error_t *err;
   fs_fs_data_t *ffd = fs->fsap_data;
   fs_fs_shared_data_t *ffsd = ffd->shared;
 
-  SVN_ERR(svn_mutex__lock(ffsd->txn_list_lock));
-
-  err = body(fs, baton, pool);
+  SVN_MUTEX__WITH_LOCK(ffsd->txn_list_lock,
+                       body(fs, baton, pool));
 
-  return svn_error_trace(svn_mutex__unlock(ffsd->txn_list_lock, err));
+  return SVN_NO_ERROR;
 }
 
 
@@ -548,24 +546,15 @@ get_lock_on_filesystem(const char *lock_
    BATON and that subpool, destroy the subpool (releasing the write
    lock) and return what BODY returned. */
 static svn_error_t *
-with_some_lock(svn_fs_t *fs,
-               svn_error_t *(*body)(void *baton,
-                                    apr_pool_t *pool),
-               void *baton,
-               const char *lock_filename,
-#if SVN_FS_FS__USE_LOCK_MUTEX
-               svn_mutex__t *lock_mutex,
-#endif
-               apr_pool_t *pool)
+with_some_lock_file(svn_fs_t *fs,
+                    svn_error_t *(*body)(void *baton,
+                                         apr_pool_t *pool),
+                    void *baton,
+                    const char *lock_filename,
+                    apr_pool_t *pool)
 {
   apr_pool_t *subpool = svn_pool_create(pool);
-  svn_error_t *err;
-
-#if SVN_FS_FS__USE_LOCK_MUTEX
-  SVN_ERR(svn_mutex__lock(lock_mutex));
-#endif
-
-  err = get_lock_on_filesystem(lock_filename, subpool);
+  svn_error_t *err = get_lock_on_filesystem(lock_filename, subpool);
 
   if (!err)
     {
@@ -583,7 +572,7 @@ with_some_lock(svn_fs_t *fs,
 
   svn_pool_destroy(subpool);
 
-  return svn_error_trace(svn_mutex__unlock(lock_mutex, err));
+  return svn_error_trace(err);
 }
 
 svn_error_t *
@@ -593,17 +582,15 @@ svn_fs_fs__with_write_lock(svn_fs_t *fs,
                            void *baton,
                            apr_pool_t *pool)
 {
-#if SVN_FS_FS__USE_LOCK_MUTEX
   fs_fs_data_t *ffd = fs->fsap_data;
   fs_fs_shared_data_t *ffsd = ffd->shared;
-#endif
 
-  return with_some_lock(fs, body, baton,
-                        path_lock(fs, pool),
-#if SVN_FS_FS__USE_LOCK_MUTEX
-                        ffsd->fs_write_lock,
-#endif
-                        pool);
+  SVN_MUTEX__WITH_LOCK(ffsd->fs_write_lock,
+                       with_some_lock_file(fs, body, baton,
+                                           path_lock(fs, pool),
+                                           pool));
+
+  return SVN_NO_ERROR;
 }
 
 /* Run BODY (with BATON and POOL) while the txn-current file
@@ -615,17 +602,15 @@ with_txn_current_lock(svn_fs_t *fs,
                       void *baton,
                       apr_pool_t *pool)
 {
-#if SVN_FS_FS__USE_LOCK_MUTEX
   fs_fs_data_t *ffd = fs->fsap_data;
   fs_fs_shared_data_t *ffsd = ffd->shared;
-#endif
 
-  return with_some_lock(fs, body, baton,
-                        path_txn_current_lock(fs, pool),
-#if SVN_FS_FS__USE_LOCK_MUTEX
-                        ffsd->txn_current_lock,
-#endif
-                        pool);
+  SVN_MUTEX__WITH_LOCK(ffsd->txn_current_lock,
+                       with_some_lock_file(fs, body, baton,
+                                           path_txn_current_lock(fs, pool),
+                                           pool));
+
+  return SVN_NO_ERROR;
 }
 
 /* A structure used by unlock_proto_rev() and unlock_proto_rev_body(),