diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2015-05-11 12:35:25 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-05-14 14:51:08 -0700 |
commit | 044b6a9efecf9941073b99ced4cb2881b18aee62 (patch) | |
tree | 5cfbf39335b835c77d09d94250c2e4aaa8c2897a /t/t7502-commit.sh | |
parent | Sync with 2.4.1 (diff) | |
download | tgif-044b6a9efecf9941073b99ced4cb2881b18aee62.tar.xz |
lockfile: allow file locking to be retried with a timeout
Currently, there is only one attempt to lock a file. If it fails, the
whole operation fails.
But it might sometimes be advantageous to try acquiring a file lock a
few times before giving up. So add a new function,
hold_lock_file_for_update_timeout(), that allows a timeout to be
specified. Make hold_lock_file_for_update() a thin wrapper around the
new function.
If timeout_ms is positive, then retry for at least that many
milliseconds to acquire the lock. On each failed attempt, use select()
to wait for a backoff time that increases quadratically (capped at 1
second) and has a random component to prevent two processes from
getting synchronized. If timeout_ms is negative, retry indefinitely.
In a moment we will switch to using the new function when locking
packed-refs.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7502-commit.sh')
0 files changed, 0 insertions, 0 deletions