Author: stefan2
Date: Sun Oct 21 14:14:58 2012
New Revision: 1400651
URL: http://svn.apache.org/viewvc?rev=1400651&view=rev
Log:
In FSFS, introduce a flag that indicates whether we currently hold
the write lock on this repository.
* subversion/libsvn_fs_fs/fs.h
(fs_fs_data_t): add the has_write_lock flag
* subversion/libsvn_fs_fs/fs_fs.c
(reset_lock_flag): new cleanup callback
(with_some_lock_file): set & reset the new flag
Modified:
subversion/trunk/subversion/libsvn_fs_fs/fs.h
subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
Modified: subversion/trunk/subversion/libsvn_fs_fs/fs.h
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/fs.h?rev=1400651&r1=1400650&r2=1400651&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs.h (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs.h Sun Oct 21 14:14:58 2012
@@ -315,6 +315,9 @@ typedef struct fs_fs_data_t
if the node has mergeinfo, "0" if it doesn't. */
svn_cache__t *mergeinfo_existence_cache;
+ /* TRUE while the we hold a lock on the write lock file. */
+ svn_boolean_t has_write_lock;
+
/* If set, there are or have been more than one concurrent transaction */
svn_boolean_t concurrent_transactions;
Modified: subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c?rev=1400651&r1=1400650&r2=1400651&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c Sun Oct 21 14:14:58 2012
@@ -589,6 +589,17 @@ get_lock_on_filesystem(const char *lock_
return svn_error_trace(err);
}
+/* Reset the HAS_WRITE_LOCK member in the FFD given as BATON_VOID.
+ When registered with the pool holding the lock on the lock file,
+ this makes sure the flag gets reset just before we release the lock. */
+static apr_status_t
+reset_lock_flag(void *baton_void)
+{
+ fs_fs_data_t *ffd = baton_void;
+ ffd->has_write_lock = FALSE;
+ return APR_SUCCESS;
+}
+
/* Obtain a write lock on the file LOCK_FILENAME (protecting with
LOCK_MUTEX if APR is threaded) in a subpool of POOL, call BODY with
BATON and that subpool, destroy the subpool (releasing the write
@@ -607,6 +618,16 @@ with_some_lock_file(svn_fs_t *fs,
if (!err)
{
fs_fs_data_t *ffd = fs->fsap_data;
+
+ /* set the "got the lock" flag and register reset function */
+ apr_pool_cleanup_register(subpool,
+ ffd,
+ reset_lock_flag,
+ apr_pool_cleanup_null);
+ ffd->has_write_lock = TRUE;
+
+ /* nobody else will modify the repo state
+ => read HEAD & pack info once */
if (ffd->format >= SVN_FS_FS__MIN_PACKED_FORMAT)
SVN_ERR(update_min_unpacked_rev(fs, pool));
SVN_ERR(get_youngest(&ffd->youngest_rev_cache, fs->path,