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
### 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 removals
......
......@@ -162,12 +162,15 @@ GIT_INLINE(bool) last_error_retryable(void)
#define do_with_retries(fn, remediation) \
do { \
int __tries, __ret; \
for (__tries = 0; __tries < git_win32__retries; __tries++) { \
if (__tries && (__ret = (remediation)) != 0) \
return __ret; \
int __retry, __ret; \
for (__retry = git_win32__retries; __retry; __retry--) { \
if ((__ret = (fn)) != GIT_RETRY) \
return __ret; \
if (__retry > 1 && (__ret = (remediation)) != 0) { \
if (__ret == GIT_RETRY) \
continue; \
return __ret; \
} \
Sleep(5); \
} \
return -1; \
......@@ -186,7 +189,7 @@ static int ensure_writable(wchar_t *path)
if (!SetFileAttributesW(path, (attrs & ~FILE_ATTRIBUTE_READONLY)))
goto on_error;
return 0;
return GIT_RETRY;
on_error:
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