summaryrefslogtreecommitdiff
path: root/refs/files-backend.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-08-26 22:55:09 -0700
committerJunio C Hamano <gitster@pobox.com>2017-08-26 22:55:09 -0700
commitf2dd90fc1c38ce1d1ebf626e39ddafad130875ae (patch)
treeefa2f719a8aa9c64c394d4ef78a02b40300cb25c /refs/files-backend.c
parent138e52ea6856c9982d61285d9ff3cb5a65f67d85 (diff)
parent4ff0f01cb7dd92fad49b4d0799590bb33a88168a (diff)
downloadgit-f2dd90fc1c38ce1d1ebf626e39ddafad130875ae.tar.gz
Merge branch 'mh/ref-lock-entry'
The code to acquire a lock on a reference (e.g. while accepting a push from a client) used to immediately fail when the reference is already locked---now it waits for a very short while and retries, which can make it succeed if the lock holder was holding it during a read-only operation. * mh/ref-lock-entry: refs: retry acquiring reference locks for 100ms
Diffstat (limited to 'refs/files-backend.c')
-rw-r--r--refs/files-backend.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 5cca55510b..fccbc24ac4 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -537,7 +537,9 @@ retry:
if (!lock->lk)
lock->lk = xcalloc(1, sizeof(struct lock_file));
- if (hold_lock_file_for_update(lock->lk, ref_file.buf, LOCK_NO_DEREF) < 0) {
+ if (hold_lock_file_for_update_timeout(
+ lock->lk, ref_file.buf, LOCK_NO_DEREF,
+ get_files_ref_lock_timeout_ms()) < 0) {
if (errno == ENOENT && --attempts_remaining > 0) {
/*
* Maybe somebody just deleted one of the
@@ -865,7 +867,9 @@ static int create_reflock(const char *path, void *cb)
{
struct lock_file *lk = cb;
- return hold_lock_file_for_update(lk, path, LOCK_NO_DEREF) < 0 ? -1 : 0;
+ return hold_lock_file_for_update_timeout(
+ lk, path, LOCK_NO_DEREF,
+ get_files_ref_lock_timeout_ms()) < 0 ? -1 : 0;
}
/*