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 2012/04/18 19:38:56 UTC
svn commit: r1327594 -
/subversion/trunk/subversion/libsvn_subr/named_atomic.c
Author: stefan2
Date: Wed Apr 18 17:38:56 2012
New Revision: 1327594
URL: http://svn.apache.org/viewvc?rev=1327594&view=rev
Log:
Automatically remove the mutex / lock file when the last atomics namespace
user releases it.
* subversion/libsvn_subr/named_atomic.c
(delete_lock_file): new cleanup callback
(svn_atomic_namespace__create): register cleanup
Modified:
subversion/trunk/subversion/libsvn_subr/named_atomic.c
Modified: subversion/trunk/subversion/libsvn_subr/named_atomic.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/named_atomic.c?rev=1327594&r1=1327593&r2=1327594&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/named_atomic.c (original)
+++ subversion/trunk/subversion/libsvn_subr/named_atomic.c Wed Apr 18 17:38:56 2012
@@ -294,6 +294,28 @@ unlock(struct mutex_t *mutex, svn_error_
unlock_err));
}
+/* The last user to close a particular namespace should also remove the
+ * lock file. Failure to do so, however, does not affect further uses
+ * of the same namespace.
+ */
+static apr_status_t
+delete_lock_file(void *arg)
+{
+ struct mutex_t *mutex = arg;
+ const char *lock_name = NULL;
+
+ /* locks have already been cleaned up. Simply close the file */
+ apr_file_close(mutex->lock_file);
+
+ /* Remove the file from disk. This will fail if there ares still other
+ * users of this lock file, i.e. namespace. */
+ apr_file_name_get(&lock_name, mutex->lock_file);
+ if (lock_name)
+ apr_file_remove(lock_name, mutex->pool);
+
+ return 0;
+}
+
/* Validate the ATOMIC parameter, i.e it's address.
*/
static svn_error_t *
@@ -358,6 +380,12 @@ svn_atomic_namespace__create(svn_atomic_
APR_OS_DEFAULT,
result_pool));
+ /* Make sure the last user of our lock file will actually remove it
+ */
+ apr_pool_cleanup_register(result_pool, &new_ns->mutex,
+ delete_lock_file,
+ apr_pool_cleanup_null);
+
/* Prevent concurrent initialization.
*/
SVN_ERR(lock(&new_ns->mutex));