summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2015-05-22 12:41:55 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-05-22 12:41:55 -0700
commitfb257bfa174b00e236ac5d6f4282a487f10a9e98 (patch)
tree616da2c04e2140fe22bd4cfaf7f3b9b764d769c3 /refs.c
parentMerge branch 'jk/add-e-kill-editor' (diff)
parentlock_packed_refs(): allow retries when acquiring the packed-refs lock (diff)
downloadtgif-fb257bfa174b00e236ac5d6f4282a487f10a9e98.tar.xz
Merge branch 'mh/lockfile-retry'
Instead of dying immediately upon failing to obtain a lock, retry after a short while with backoff. * mh/lockfile-retry: lock_packed_refs(): allow retries when acquiring the packed-refs lock lockfile: allow file locking to be retried with a timeout
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/refs.c b/refs.c
index f704ee285c..8480d8dbf5 100644
--- a/refs.c
+++ b/refs.c
@@ -2505,9 +2505,19 @@ static int write_packed_entry_fn(struct ref_entry *entry, void *cb_data)
/* This should return a meaningful errno on failure */
int lock_packed_refs(int flags)
{
+ static int timeout_configured = 0;
+ static int timeout_value = 1000;
+
struct packed_ref_cache *packed_ref_cache;
- if (hold_lock_file_for_update(&packlock, git_path("packed-refs"), flags) < 0)
+ if (!timeout_configured) {
+ git_config_get_int("core.packedrefstimeout", &timeout_value);
+ timeout_configured = 1;
+ }
+
+ if (hold_lock_file_for_update_timeout(
+ &packlock, git_path("packed-refs"),
+ flags, timeout_value) < 0)
return -1;
/*
* Get the current packed-refs while holding the lock. If the