Skip to content

Commit 7ece906

Browse files
committed
win32: make posix emulation retries configurable
POSIX emulation retries should be configurable so that tests can disable them. In particular, maniacally threading tests may end up trying to open locked files and need retries, which will slow continuous integration tests significantly.
1 parent 1069ad3 commit 7ece906

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/win32/posix.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "dir.h"
1616

1717
extern unsigned long git_win32__createfile_sharemode;
18+
extern int git_win32__retries;
1819

1920
typedef SOCKET GIT_SOCKET;
2021

src/win32/posix_w32.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ typedef DWORD(WINAPI *PFGetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD, DWORD)
3737

3838
unsigned long git_win32__createfile_sharemode =
3939
FILE_SHARE_READ | FILE_SHARE_WRITE;
40+
int git_win32__retries = 10;
4041

4142
GIT_INLINE(void) set_errno(void)
4243
{
@@ -162,7 +163,7 @@ GIT_INLINE(bool) last_error_retryable(void)
162163
#define do_with_retries(fn, cleanup) \
163164
do { \
164165
int __tries, __ret; \
165-
for (__tries = 0; __tries < 10; __tries++) { \
166+
for (__tries = 0; __tries < git_win32__retries; __tries++) { \
166167
if (__tries && (__ret = (cleanup)) != 0) \
167168
return __ret; \
168169
if ((__ret = (fn)) != GIT_RETRY) \

tests/threads/diff.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,20 @@ static git_repository *_repo;
1919
static git_tree *_a, *_b;
2020
static git_atomic _counts[4];
2121
static int _check_counts;
22+
static int _retries;
2223

2324
#define THREADS 20
2425

26+
void test_threads_diff__initialize(void)
27+
{
28+
_retries = git_win32__retries;
29+
git_win32__retries = 1;
30+
}
31+
2532
void test_threads_diff__cleanup(void)
2633
{
2734
cl_git_sandbox_cleanup();
35+
git_win32__retries = _retries;
2836
}
2937

3038
static void setup_trees(void)

0 commit comments

Comments
 (0)