]> git.proxmox.com Git - libgit2.git/commitdiff
win32: make posix emulation retries configurable
authorEdward Thomson <ethomson@edwardthomson.com>
Mon, 3 Apr 2017 22:07:16 +0000 (23:07 +0100)
committerEdward Thomson <ethomson@edwardthomson.com>
Mon, 3 Apr 2017 22:14:24 +0000 (23:14 +0100)
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.

src/win32/posix.h
src/win32/posix_w32.c
tests/threads/diff.c

index 0ba05a16fbe22fa0299234e7ea52b136479da04a..64769ecd32eebb4445925456c7314762cc84a9d0 100644 (file)
@@ -15,6 +15,7 @@
 #include "dir.h"
 
 extern unsigned long git_win32__createfile_sharemode;
+extern int git_win32__retries;
 
 typedef SOCKET GIT_SOCKET;
 
index 874892eb649c7eb2e1a9f6fbe0f4872baf914461..bf132966d2b2cf201ff9c0ab572adaba5febd60a 100644 (file)
@@ -37,6 +37,7 @@ typedef DWORD(WINAPI *PFGetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD, DWORD)
 
 unsigned long git_win32__createfile_sharemode =
  FILE_SHARE_READ | FILE_SHARE_WRITE;
+int git_win32__retries = 10;
 
 GIT_INLINE(void) set_errno(void)
 {
@@ -162,7 +163,7 @@ GIT_INLINE(bool) last_error_retryable(void)
 #define do_with_retries(fn, cleanup) \
        do {                                                             \
                int __tries, __ret;                                          \
-               for (__tries = 0; __tries < 10; __tries++) {                 \
+               for (__tries = 0; __tries < git_win32__retries; __tries++) { \
                        if (__tries && (__ret = (cleanup)) != 0)                 \
                                return __ret;                                        \
                        if ((__ret = (fn)) != GIT_RETRY)                         \
index c328114691252fed30a35cf92e54fc6a1190004e..92fd7061becde90bfbd91a37e4c4ee3505961fba 100644 (file)
@@ -19,12 +19,20 @@ static git_repository *_repo;
 static git_tree *_a, *_b;
 static git_atomic _counts[4];
 static int _check_counts;
+static int _retries;
 
 #define THREADS 20
 
+void test_threads_diff__initialize(void)
+{
+       _retries = git_win32__retries;
+       git_win32__retries = 1;
+}
+
 void test_threads_diff__cleanup(void)
 {
        cl_git_sandbox_cleanup();
+       git_win32__retries = _retries;
 }
 
 static void setup_trees(void)