git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] crendential-store: use timeout when locking file

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 24, 2020, 22:08 UTC
Message-ID
<xmqq4kleif26.fsf@gitster.c.googlers.com>
In-Reply-To
<20201124193208.74fe4mticgkbxou3@safonso-t430>
Simão Afonso <simao.afonso@powertools-tech.com> writes:
Show 5 quoted lines
> +credentialStore.fileTimeout::
> +	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).

I do not remember what was said in the first round of the review, but I wonder if this is the best name for users. I think it is good enough, but do ".lockTimeout" or ".lockTimeoutMS" make it even easier to grok, perhaps?

Show 18 quoted lines
> diff --git a/builtin/credential-store.c b/builtin/credential-store.c
> index 5331ab151..82284176e 100644
> --- a/builtin/credential-store.c
> +++ b/builtin/credential-store.c
> @@ -1,4 +1,5 @@
>  #include "builtin.h"
> +#include "config.h"
>  #include "lockfile.h"
>  #include "credential.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,
>  				    struct strbuf *extra)
>  {
> -	if (hold_lock_file_for_update(&credential_lock, fn, 0) < 0)
> -		die_errno("unable to get credential storage lock");
> +	int timeout_ms = 1000;
> +	git_config_get_int("credentialstore.filetimeout", &timeout_ms);
Please have a blank line before the first statement.
> +
> +	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);

Should this be die_errno()? Looking at lock_file_timeout(), I am not sure if the value of errno is valid in all codepaths that return failure.

In any case, the message should be markd with _() for translation.
Other than that, it looks good.
Thanks.
>  	if (extra)
>  		print_line(extra);
>  	parse_credential_file(fn, c, NULL, print_line);
Previous: Simão AfonsoNext: Jeff King
Message 4 of 7 in “credential-store: use timeout when locking file”
  1. credential-store: use timeout when locking fileSimão Afonso, Oct 30, 2020
  2. Junio C HamanoOct 30, 2020
  3. crendential-store: use timeout when locking fileSimão Afonso, Nov 24, 2020
  4. Junio C HamanoNov 24, 2020
  5. Jeff KingNov 25, 2020
  6. crendential-store: use timeout when locking fileSimão Afonso, Nov 25, 2020
  7. Jeff KingNov 26, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.