Merge branch 'sa/credential-store-timeout'
Multiple "credential-store" backends can race to lock the same file, causing everybody else but one to fail---reattempt locking with some timeout to reduce the rate of the failure. * sa/credential-store-timeout: crendential-store: use timeout when locking file
This commit is contained in:
commit
3d8f81f21b
@ -28,3 +28,9 @@ credential.<url>.*::
|
|||||||
|
|
||||||
credentialCache.ignoreSIGHUP::
|
credentialCache.ignoreSIGHUP::
|
||||||
Tell git-credential-cache--daemon to ignore SIGHUP, instead of quitting.
|
Tell git-credential-cache--daemon to ignore SIGHUP, instead of quitting.
|
||||||
|
|
||||||
|
credentialStore.lockTimeoutMS::
|
||||||
|
The length of time, in milliseconds, for git-credential-store to retry
|
||||||
|
when trying to lock the credentials file. Value 0 means not to retry at
|
||||||
|
all; -1 means to try indefinitely. Default is 1000 (i.e., retry for
|
||||||
|
1s).
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "builtin.h"
|
#include "builtin.h"
|
||||||
|
#include "config.h"
|
||||||
#include "lockfile.h"
|
#include "lockfile.h"
|
||||||
#include "credential.h"
|
#include "credential.h"
|
||||||
#include "string-list.h"
|
#include "string-list.h"
|
||||||
@ -58,8 +59,11 @@ static void print_line(struct strbuf *buf)
|
|||||||
static void rewrite_credential_file(const char *fn, struct credential *c,
|
static void rewrite_credential_file(const char *fn, struct credential *c,
|
||||||
struct strbuf *extra)
|
struct strbuf *extra)
|
||||||
{
|
{
|
||||||
if (hold_lock_file_for_update(&credential_lock, fn, 0) < 0)
|
int timeout_ms = 1000;
|
||||||
die_errno("unable to get credential storage lock");
|
|
||||||
|
git_config_get_int("credentialstore.locktimeoutms", &timeout_ms);
|
||||||
|
if (hold_lock_file_for_update_timeout(&credential_lock, fn, 0, timeout_ms) < 0)
|
||||||
|
die_errno(_("unable to get credential storage lock in %d ms"), timeout_ms);
|
||||||
if (extra)
|
if (extra)
|
||||||
print_line(extra);
|
print_line(extra);
|
||||||
parse_credential_file(fn, c, NULL, print_line);
|
parse_credential_file(fn, c, NULL, print_line);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user