On Wed, Nov 25, 2009 at 07:28:22PM +0000, Philip Martin wrote:
> "Jon Foster" <[email protected]> writes:
> 
> > A patch is attached.  The patch is against 1.6.6.  I've tried to
> > keep the changes minimal, because I think this might be a candidate
> > for a Subversion 1.6.7 patch release.
> 
> A minimal patch is something like this:
> 
> Index: subversion/svnsync/main.c
> ===================================================================
> --- subversion/svnsync/main.c (revision 884213)
> +++ subversion/svnsync/main.c (working copy)
> @@ -299,7 +299,7 @@
>                apr_sleep(apr_time_from_sec(1));
>              }
>          }
> -      else
> +      else if (i != 9)
>          {
>            SVN_ERR(svn_ra_change_rev_prop(session, 0, SVNSYNC_PROP_LOCK,
>                                           mylocktoken, subpool));
> 
> 
> A #define to allow XXX-1 rather than 9 might be better.

What about the patch below?

[[[
* subversion/svnsync/main.c
  (get_lock): The lock attempt is done in iteration N, and success is
   checked in iteration N+1. Prevent the case where svnsync attempts
   to take the lock in the very last iteration, doesn't check for
   success, and ends up erroring out, leaving behind a stale lock.

Found by: Jon Foster <[email protected]>
Based on patch by: philip
]]]

Index: subversion/svnsync/main.c
===================================================================
--- subversion/svnsync/main.c   (revision 884790)
+++ subversion/svnsync/main.c   (working copy)
@@ -276,7 +276,8 @@ get_lock(svn_ra_session_t *session, apr_pool_t *po
 
   subpool = svn_pool_create(pool);
 
-  for (i = 0; i < 10; ++i)
+#define SVNSYNC_LOCK_RETRIES 10
+  for (i = 0; i < SVNSYNC_LOCK_RETRIES; ++i)
     {
       svn_pool_clear(subpool);
       SVN_ERR(check_cancel(NULL));
@@ -299,8 +300,9 @@ get_lock(svn_ra_session_t *session, apr_pool_t *po
               apr_sleep(apr_time_from_sec(1));
             }
         }
-      else
+      else if (i < SVNSYNC_LOCK_RETRIES - 1)
         {
+          /* Except in the very last iteration, try to set the lock. */
           SVN_ERR(svn_ra_change_rev_prop(session, 0, SVNSYNC_PROP_LOCK,
                                          mylocktoken, subpool));
         }

Reply via email to