diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-12-24 17:51:19 +0000 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2016-11-14 11:35:38 +0100 |
commit | 26416f6d20044d693ddfb57d719ee5183c065fc5 (patch) | |
tree | 54c4bc4405288eec7233c97f9bebe3a26a6c2f6e /tests/threads | |
parent | 2e09106e7a8711e3a4a70ef304643d28f2763c11 (diff) | |
download | libgit2-26416f6d20044d693ddfb57d719ee5183c065fc5.tar.gz |
refdb: add retry logic to the threaded tests
The logic simply consists of retrying for as long as the library says
the data is locked, but it eventually gets through.
Diffstat (limited to 'tests/threads')
-rw-r--r-- | tests/threads/refdb.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/threads/refdb.c b/tests/threads/refdb.c index 9b1b37592..0c5cd2be6 100644 --- a/tests/threads/refdb.c +++ b/tests/threads/refdb.c @@ -52,7 +52,7 @@ static void *iterate_refs(void *arg) static void *create_refs(void *arg) { - int i; + int i, error; struct th_data *data = (struct th_data *) arg; git_oid head; char name[128]; @@ -70,7 +70,9 @@ static void *create_refs(void *arg) if (i == 5) { git_refdb *refdb; cl_git_pass(git_repository_refdb(&refdb, repo)); - cl_git_pass(git_refdb_compress(refdb)); + do { + error = git_refdb_compress(refdb); + } while (error == GIT_ELOCKED); git_refdb_free(refdb); } } @@ -86,7 +88,7 @@ static void *create_refs(void *arg) static void *delete_refs(void *arg) { - int i; + int i, error; struct th_data *data = (struct th_data *) arg; git_reference *ref; char name[128]; @@ -99,14 +101,20 @@ static void *delete_refs(void *arg) name, sizeof(name), "refs/heads/thread-%03d-%02d", (data->id) & ~0x3, i); if (!git_reference_lookup(&ref, repo, name)) { - cl_git_pass(git_reference_delete(ref)); + do { + error = git_reference_delete(ref); + } while (error == GIT_ELOCKED); + cl_git_pass(error); git_reference_free(ref); } if (i == 5) { git_refdb *refdb; cl_git_pass(git_repository_refdb(&refdb, repo)); - cl_git_pass(git_refdb_compress(refdb)); + do { + error = git_refdb_compress(refdb); + } while (error == GIT_ELOCKED); + cl_git_pass(error); git_refdb_free(refdb); } } |