Re: [PATCH v2 17/17] rename_tmp_log(): on SCLD_VANISHED, retry

2014-01-07 Thread Michael Haggerty
On 01/06/2014 07:21 PM, Junio C Hamano wrote:
 Michael Haggerty mhag...@alum.mit.edu writes:
 
 If safe_create_leading_directories() fails because a file along the
 path unexpectedly vanished, try again from the beginning.  Try at most
 3 times.
 
 As the previous step bumped it from 3 to 4 without explanation, the
 above no longer reflects reality ;-)

Good catch.  The increment 3 - 4 was because the first call to rename()
is optimistic, and can fail once even if there is no race.  I will
change the commit message of 16/17 to explain this point, and of 17/17
to match reality.

 The series mostly looked sane from a cursory read.
 
 Will re-queue.  Thanks.

Michael

-- 
Michael Haggerty
mhag...@alum.mit.edu
http://softwareswirl.blogspot.com/
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 17/17] rename_tmp_log(): on SCLD_VANISHED, retry

2014-01-06 Thread Michael Haggerty
If safe_create_leading_directories() fails because a file along the
path unexpectedly vanished, try again from the beginning.  Try at most
3 times.

Signed-off-by: Michael Haggerty mhag...@alum.mit.edu
---
 refs.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/refs.c b/refs.c
index 490525a..810f802 100644
--- a/refs.c
+++ b/refs.c
@@ -2533,7 +2533,14 @@ static int rename_tmp_log(const char *newrefname)
int attempts = 4;
 
  retry:
-   if (safe_create_leading_directories(git_path(logs/%s, newrefname))) {
+   switch (safe_create_leading_directories(git_path(logs/%s, 
newrefname))) {
+   case SCLD_OK:
+   break; /* success */
+   case SCLD_VANISHED:
+   if (--attempts  0)
+   goto retry;
+   /* fall through */
+   default:
error(unable to create directory for %s, newrefname);
return -1;
}
-- 
1.8.5.2

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 17/17] rename_tmp_log(): on SCLD_VANISHED, retry

2014-01-06 Thread Junio C Hamano
Michael Haggerty mhag...@alum.mit.edu writes:

 If safe_create_leading_directories() fails because a file along the
 path unexpectedly vanished, try again from the beginning.  Try at most
 3 times.

As the previous step bumped it from 3 to 4 without explanation, the
above no longer reflects reality ;-)

The series mostly looked sane from a cursory read.

Will re-queue.  Thanks.



 Signed-off-by: Michael Haggerty mhag...@alum.mit.edu
 ---
  refs.c | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)

 diff --git a/refs.c b/refs.c
 index 490525a..810f802 100644
 --- a/refs.c
 +++ b/refs.c
 @@ -2533,7 +2533,14 @@ static int rename_tmp_log(const char *newrefname)
   int attempts = 4;
  
   retry:
 - if (safe_create_leading_directories(git_path(logs/%s, newrefname))) {
 + switch (safe_create_leading_directories(git_path(logs/%s, 
 newrefname))) {
 + case SCLD_OK:
 + break; /* success */
 + case SCLD_VANISHED:
 + if (--attempts  0)
 + goto retry;
 + /* fall through */
 + default:
   error(unable to create directory for %s, newrefname);
   return -1;
   }
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html