Commit 20d30000 by Edward Thomson Committed by GitHub

Merge pull request #4311 from libgit2/ethomson/win32_remediate

win32: provide fast-path for retrying filesystem operations
parents e0568621 bc35fd4b
...@@ -3,6 +3,9 @@ v0.26 + 1 ...@@ -3,6 +3,9 @@ v0.26 + 1
### Changes or improvements ### Changes or improvements
* Improved `p_unlink` in `posix_w32.c` to try and make a file writable
before sleeping in the retry loop to prevent unnecessary calls to sleep.
### API additions ### API additions
### API removals ### API removals
......
...@@ -162,12 +162,15 @@ GIT_INLINE(bool) last_error_retryable(void) ...@@ -162,12 +162,15 @@ GIT_INLINE(bool) last_error_retryable(void)
#define do_with_retries(fn, remediation) \ #define do_with_retries(fn, remediation) \
do { \ do { \
int __tries, __ret; \ int __retry, __ret; \
for (__tries = 0; __tries < git_win32__retries; __tries++) { \ for (__retry = git_win32__retries; __retry; __retry--) { \
if (__tries && (__ret = (remediation)) != 0) \
return __ret; \
if ((__ret = (fn)) != GIT_RETRY) \ if ((__ret = (fn)) != GIT_RETRY) \
return __ret; \ return __ret; \
if (__retry > 1 && (__ret = (remediation)) != 0) { \
if (__ret == GIT_RETRY) \
continue; \
return __ret; \
} \
Sleep(5); \ Sleep(5); \
} \ } \
return -1; \ return -1; \
...@@ -186,7 +189,7 @@ static int ensure_writable(wchar_t *path) ...@@ -186,7 +189,7 @@ static int ensure_writable(wchar_t *path)
if (!SetFileAttributesW(path, (attrs & ~FILE_ATTRIBUTE_READONLY))) if (!SetFileAttributesW(path, (attrs & ~FILE_ATTRIBUTE_READONLY)))
goto on_error; goto on_error;
return 0; return GIT_RETRY;
on_error: on_error:
set_errno(); set_errno();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment