You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2014/04/04 21:59:17 UTC

svn commit: r1584879 - in /subversion/trunk/subversion: include/svn_error_codes.h libsvn_fs_fs/lock.c

Author: philip
Date: Fri Apr  4 19:59:16 2014
New Revision: 1584879

URL: http://svn.apache.org/r1584879
Log:
Don't assume absence of fs_err indicates lock_body/unlock_body was
successful.  This handles conditions like disk full or obstructions
in db/locks.

* subversion/include/svn_error_codes.h
  (SVN_ERR_FS_LOCK_OPERATION_FAILED): New.

* subversion/libsvn_fs_fs/lock.c
  (struct unlock_info_t): Add done member.
  (unlock_body): Set done when unlock is successful.
  (svn_fs_fs__lock): Generate an error if there is no lock and no fs_err.
  (svn_fs_fs__unlock): Generate an error if the done flag is not set
   and there is no fs_err.

Modified:
    subversion/trunk/subversion/include/svn_error_codes.h
    subversion/trunk/subversion/libsvn_fs_fs/lock.c

Modified: subversion/trunk/subversion/include/svn_error_codes.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_error_codes.h?rev=1584879&r1=1584878&r2=1584879&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_error_codes.h (original)
+++ subversion/trunk/subversion/include/svn_error_codes.h Fri Apr  4 19:59:16 2014
@@ -851,6 +851,11 @@ SVN_ERROR_START
              SVN_ERR_FS_CATEGORY_START + 60,
              "Move without a suitable deletion")
 
+  /** @since New in 1.9. */
+  SVN_ERRDEF(SVN_ERR_FS_LOCK_OPERATION_FAILED,
+             SVN_ERR_FS_CATEGORY_START + 61,
+             "Lock operation failed")
+
   /* repos errors */
 
   SVN_ERRDEF(SVN_ERR_REPOS_LOCKED,

Modified: subversion/trunk/subversion/libsvn_fs_fs/lock.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/lock.c?rev=1584879&r1=1584878&r2=1584879&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/lock.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/lock.c Fri Apr  4 19:59:16 2014
@@ -1031,6 +1031,7 @@ struct unlock_info_t {
   const char *path;
   const char *component;
   svn_error_t *fs_err;
+  svn_boolean_t done;
   int components;
 };
 
@@ -1116,6 +1117,7 @@ unlock_body(void *baton, apr_pool_t *poo
               if (info->components == i)
                 {
                   SVN_ERR(delete_lock(ub->fs->path, info->path, iterpool));
+                  info->done = TRUE;
                 }
               else if (info->components > i)
                 {
@@ -1250,8 +1252,15 @@ svn_fs_fs__lock(svn_fs_t *fs,
       struct lock_info_t *info = &APR_ARRAY_IDX(lb.infos, i,
                                                 struct lock_info_t);
       if (!cb_err && lock_callback)
-        cb_err = lock_callback(lock_baton, info->path, info->lock,
-                               info->fs_err, scratch_pool);
+        {
+          if (!info->lock && !info->fs_err)
+            info->fs_err = svn_error_createf(SVN_ERR_FS_LOCK_OPERATION_FAILED,
+                                             0, _("Failed to lock '%s'"),
+                                             info->path);
+                                             
+          cb_err = lock_callback(lock_baton, info->path, info->lock,
+                                 info->fs_err, scratch_pool);
+        }
       svn_error_clear(info->fs_err);
     }
 
@@ -1331,8 +1340,14 @@ svn_fs_fs__unlock(svn_fs_t *fs,
       struct unlock_info_t *info = &APR_ARRAY_IDX(ub.infos, i,
                                                   struct unlock_info_t);
       if (!cb_err && lock_callback)
-        cb_err = lock_callback(lock_baton, info->path, NULL, info->fs_err,
-                               scratch_pool);
+        {
+          if (!info->done && !info->fs_err)
+            info->fs_err = svn_error_createf(SVN_ERR_FS_LOCK_OPERATION_FAILED,
+                                             0, _("Failed to unlock '%s'"),
+                                             info->path);
+          cb_err = lock_callback(lock_baton, info->path, NULL, info->fs_err,
+                                 scratch_pool);
+        }
       svn_error_clear(info->fs_err);
     }