summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2015-05-11 10:35:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-05-14 21:51:08 (GMT)
commit044b6a9efecf9941073b99ced4cb2881b18aee62 (patch)
tree5cfbf39335b835c77d09d94250c2e4aaa8c2897a /refs.c
parent1ea28e149403ba92f95205f324cc3119fb92df07 (diff)
downloadgit-044b6a9efecf9941073b99ced4cb2881b18aee62.zip
git-044b6a9efecf9941073b99ced4cb2881b18aee62.tar.gz
git-044b6a9efecf9941073b99ced4cb2881b18aee62.tar.bz2
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 'refs.c')
0 files changed, 0 insertions, 0 deletions