Author: philip
Date: Wed May 13 22:22:21 2015
New Revision: 1679287

URL: http://svn.apache.org/r1679287
Log:
Followup to r1679169: port FSFS changes to FSX, skip test for BDB.

* subversion/tests/libsvn_fs/fs-test.c
  (freeze_and_commit): Skip for BDB.

* subversion/libsvn_fs_x/rep-cache.h
  (svn_fs_x__lock_rep_cache): Remove declaration.
  (svn_fs_x__with_rep_cache_lock): New declaration.

* subversion/libsvn_fs_x/rep-cache-db.sql
  (STMT_UNLOCK_REP): New statement.

* subversion/libsvn_fs_x/fs.c
  (fs_freeze_body): Unlock the rep cache after calling freeze_func().

* subversion/libsvn_fs_x/rep-cache.c
  (svn_fs_x__lock_rep_cache): Demote to a static function, renaming to..
  (lock_rep_cache): .. this.
  (unlock_rep_cache): New static function.
  (svn_fs_x__with_rep_cache_lock): New function.

Modified:
    subversion/trunk/subversion/libsvn_fs_x/fs.c
    subversion/trunk/subversion/libsvn_fs_x/rep-cache-db.sql
    subversion/trunk/subversion/libsvn_fs_x/rep-cache.c
    subversion/trunk/subversion/libsvn_fs_x/rep-cache.h
    subversion/trunk/subversion/tests/libsvn_fs/fs-test.c

Modified: subversion/trunk/subversion/libsvn_fs_x/fs.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/fs.c?rev=1679287&r1=1679286&r2=1679287&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/fs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/fs.c Wed May 13 22:22:21 2015
@@ -164,9 +164,11 @@ x_freeze_body(void *baton,
 
   SVN_ERR(svn_fs_x__exists_rep_cache(&exists, b->fs, scratch_pool));
   if (exists)
-    SVN_ERR(svn_fs_x__lock_rep_cache(b->fs, scratch_pool));
-
-  SVN_ERR(b->freeze_func(b->freeze_baton, scratch_pool));
+    SVN_ERR(svn_fs_x__with_rep_cache_lock(b->fs,
+                                          b->freeze_func, b->freeze_baton,
+                                          scratch_pool));
+  else
+    SVN_ERR(b->freeze_func(b->freeze_baton, scratch_pool));
 
   return SVN_NO_ERROR;
 }

Modified: subversion/trunk/subversion/libsvn_fs_x/rep-cache-db.sql
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/rep-cache-db.sql?rev=1679287&r1=1679286&r2=1679287&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/rep-cache-db.sql (original)
+++ subversion/trunk/subversion/libsvn_fs_x/rep-cache-db.sql Wed May 13 
22:22:21 2015
@@ -65,3 +65,6 @@ WHERE revision > ?1
 -- STMT_LOCK_REP
 BEGIN TRANSACTION;
 INSERT INTO rep_cache VALUES ('dummy', 0, 0, 0, 0)
+
+-- STMT_UNLOCK_REP
+ROLLBACK TRANSACTION;

Modified: subversion/trunk/subversion/libsvn_fs_x/rep-cache.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/rep-cache.c?rev=1679287&r1=1679286&r2=1679287&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/rep-cache.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/rep-cache.c Wed May 13 22:22:21 2015
@@ -369,16 +369,48 @@ svn_fs_x__del_rep_reference(svn_fs_t *fs
   return SVN_NO_ERROR;
 }
 
-svn_error_t *
-svn_fs_x__lock_rep_cache(svn_fs_t *fs,
-                         apr_pool_t *scratch_pool)
+/* Start a transaction to take an SQLite reserved lock that prevents
+   other writes.
+
+   See unlock_rep_cache(). */
+static svn_error_t *
+lock_rep_cache(svn_fs_t *fs,
+               apr_pool_t *pool)
 {
   svn_fs_x__data_t *ffd = fs->fsap_data;
 
   if (! ffd->rep_cache_db)
-    SVN_ERR(svn_fs_x__open_rep_cache(fs, scratch_pool));
+    SVN_ERR(svn_fs_x__open_rep_cache(fs, pool));
 
   SVN_ERR(svn_sqlite__exec_statements(ffd->rep_cache_db, STMT_LOCK_REP));
 
   return SVN_NO_ERROR;
 }
+
+/* End the transaction started by lock_rep_cache(). */
+static svn_error_t *
+unlock_rep_cache(svn_fs_t *fs,
+                 apr_pool_t *pool)
+{
+  svn_fs_x__data_t *ffd = fs->fsap_data;
+
+  SVN_ERR_ASSERT(ffd->rep_cache_db); /* was opened by lock_rep_cache() */
+
+  SVN_ERR(svn_sqlite__exec_statements(ffd->rep_cache_db, STMT_UNLOCK_REP));
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_fs_x__with_rep_cache_lock(svn_fs_t *fs,
+                              svn_error_t *(*body)(void *,
+                                                   apr_pool_t *),
+                              void *baton,
+                              apr_pool_t *pool)
+{
+  svn_error_t *err;
+
+  SVN_ERR(lock_rep_cache(fs, pool));
+  err = body(baton, pool);
+  return svn_error_compose_create(err, unlock_rep_cache(fs, pool));
+}

Modified: subversion/trunk/subversion/libsvn_fs_x/rep-cache.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/rep-cache.h?rev=1679287&r1=1679286&r2=1679287&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/rep-cache.h (original)
+++ subversion/trunk/subversion/libsvn_fs_x/rep-cache.h Wed May 13 22:22:21 2015
@@ -88,12 +88,16 @@ svn_fs_x__del_rep_reference(svn_fs_t *fs
                             svn_revnum_t youngest,
                             apr_pool_t *scratch_pool);
 
+
 /* Start a transaction to take an SQLite reserved lock that prevents
-   other writes. */
+   other writes, call BODY, end the transaction, and return what BODY returned.
+ */
 svn_error_t *
-svn_fs_x__lock_rep_cache(svn_fs_t *fs,
-                         apr_pool_t *scratch_pool);
-
+svn_fs_x__with_rep_cache_lock(svn_fs_t *fs,
+                              svn_error_t *(*body)(void *baton,
+                                                   apr_pool_t *pool),
+                              void *baton,
+                              apr_pool_t *pool);
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/trunk/subversion/tests/libsvn_fs/fs-test.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_fs/fs-test.c?rev=1679287&r1=1679286&r2=1679287&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_fs/fs-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_fs/fs-test.c Wed May 13 22:22:21 
2015
@@ -6908,6 +6908,10 @@ freeze_and_commit(const svn_test_opts_t
   svn_revnum_t new_rev = 0;
   apr_pool_t *subpool = svn_pool_create(pool);
 
+  if (!strcmp(opts->fs_type, "bdb"))
+    return svn_error_create(SVN_ERR_TEST_SKIPPED, NULL,
+                            "this will not test BDB repositories");
+
   SVN_ERR(svn_test__create_fs(&fs, "test-freeze-and-commit", opts, subpool));
 
   /* This test used to FAIL with an SQLite error since svn_fs_freeze()


Reply via email to