subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1612529 - in /subversion/branches/1.8.x-r1611379: ./ subversion/include/private/svn_io_private.h subversion/libsvn_subr/io.c subversion/libsvn_subr/named_atomic.c
Date Tue, 22 Jul 2014 10:12:25 GMT
Author: stefan2
Date: Tue Jul 22 10:12:25 2014
New Revision: 1612529

URL: http://svn.apache.org/r1612529
Log:
Cleanly merge r1612405 from /trunk.

Note, this will not compile due to usage of svn_io_file_create_empty().
Build will be fixed after all patches have been merged.

Modified:
    subversion/branches/1.8.x-r1611379/   (props changed)
    subversion/branches/1.8.x-r1611379/subversion/include/private/svn_io_private.h
    subversion/branches/1.8.x-r1611379/subversion/libsvn_subr/io.c
    subversion/branches/1.8.x-r1611379/subversion/libsvn_subr/named_atomic.c

Propchange: subversion/branches/1.8.x-r1611379/
------------------------------------------------------------------------------
  Merged /subversion/trunk:r1612405

Modified: subversion/branches/1.8.x-r1611379/subversion/include/private/svn_io_private.h
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x-r1611379/subversion/include/private/svn_io_private.h?rev=1612529&r1=1612528&r2=1612529&view=diff
==============================================================================
--- subversion/branches/1.8.x-r1611379/subversion/include/private/svn_io_private.h (original)
+++ subversion/branches/1.8.x-r1611379/subversion/include/private/svn_io_private.h Tue Jul
22 10:12:25 2014
@@ -64,6 +64,18 @@ svn_io__is_finfo_read_only(svn_boolean_t
                            apr_pool_t *pool);
 
 
+/**
+ * Lock file at @a lock_file. If that file does not exist, create an empty
+ * file.
+ *
+ * Lock will be automatically released when @a pool is cleared or destroyed.
+ * Use @a pool for memory allocations.
+ */
+svn_error_t *
+svn_io__file_lock_autocreate(const char *lock_file,
+                             apr_pool_t *pool);
+
+
 /** Buffer test handler function for a generic stream. @see svn_stream_t
  * and svn_stream__is_buffered().
  *

Modified: subversion/branches/1.8.x-r1611379/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x-r1611379/subversion/libsvn_subr/io.c?rev=1612529&r1=1612528&r2=1612529&view=diff
==============================================================================
--- subversion/branches/1.8.x-r1611379/subversion/libsvn_subr/io.c (original)
+++ subversion/branches/1.8.x-r1611379/subversion/libsvn_subr/io.c Tue Jul 22 10:12:25 2014
@@ -2089,6 +2089,35 @@ svn_io_file_lock2(const char *lock_file,
   return svn_io_lock_open_file(lockfile_handle, exclusive, nonblocking, pool);
 }
 
+svn_error_t *
+svn_io__file_lock_autocreate(const char *lock_file,
+                             apr_pool_t *pool)
+{
+  svn_error_t *err
+    = svn_io_file_lock2(lock_file, TRUE, FALSE, pool);
+  if (err && APR_STATUS_IS_ENOENT(err->apr_err))
+    {
+      /* No lock file?  No big deal; these are just empty files anyway.
+         Create it and try again. */
+      svn_error_clear(err);
+
+      /* This file creation is racy.
+         We don't care as long as file gets created at all. */
+      err = svn_io_file_create_empty(lock_file, pool);
+      if (err && APR_STATUS_IS_EEXIST(err->apr_err))
+        {
+          svn_error_clear(err);
+          err = NULL;
+        }
+
+      /* Finally, lock the file - if it exists */
+      if (!err)
+        err = svn_io_file_lock2(lock_file, TRUE, FALSE, pool);
+    }
+
+  return svn_error_trace(err);
+}
+
 
 
 /* Data consistency/coherency operations. */

Modified: subversion/branches/1.8.x-r1611379/subversion/libsvn_subr/named_atomic.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.8.x-r1611379/subversion/libsvn_subr/named_atomic.c?rev=1612529&r1=1612528&r2=1612529&view=diff
==============================================================================
--- subversion/branches/1.8.x-r1611379/subversion/libsvn_subr/named_atomic.c (original)
+++ subversion/branches/1.8.x-r1611379/subversion/libsvn_subr/named_atomic.c Tue Jul 22 10:12:25
2014
@@ -32,6 +32,7 @@
 #include "svn_pools.h"
 #include "svn_dirent_uri.h"
 #include "svn_io.h"
+#include "private/svn_io_private.h"
 
 /* Implementation aspects.
  *
@@ -274,28 +275,10 @@ init_thread_mutex(void *baton, apr_pool_
 static svn_error_t *
 lock(struct mutex_t *mutex)
 {
-  svn_error_t *err;
-
-  /* Intra-process lock */
-  SVN_ERR(svn_mutex__lock(thread_mutex));
-
-  /* Inter-process lock. */
-  err = svn_io_file_lock2(mutex->lock_name, TRUE, FALSE, mutex->pool);
-  if (err && APR_STATUS_IS_ENOENT(err->apr_err))
-    {
-      /* No lock file?  No big deal; these are just empty files anyway.
-         Create it and try again. */
-      svn_error_clear(err);
-      err = NULL;
-
-      SVN_ERR(svn_io_file_create_empty(mutex->lock_name, mutex->pool));
-      SVN_ERR(svn_io_file_lock2(mutex->lock_name, TRUE, FALSE, mutex->pool));
-    }
-
-  /* Don't leave us in a semi-locked state ... */
-  return err
-    ? svn_mutex__unlock(thread_mutex, err)
-    : err;
+  SVN_MUTEX__WITH_LOCK(thread_mutex,
+                       svn_io__file_lock_autocreate(mutex->lock_name,
+                                                    mutex->pool));
+  return SVN_NO_ERROR;
 }
 
 /* Utility that releases the lock previously acquired via lock().  If the



Mime
View raw message