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

Re: What should happen in credential-cache on recoverable error without SPAWN option?

From
Jeff King <peff@peff.net>
Date
Sep 14, 2021, 19:33 UTC
Message-ID
<YUD5I/hwxpcyocEU@coredump.intra.peff.net>
In-Reply-To
<xmqqilz30yap.fsf@gitster.g>
On Tue, Sep 14, 2021 at 12:09:18PM -0700, Junio C Hamano wrote:
Show 18 quoted lines
> While reviewing Carlo's "credential-cache: check for windows
> specific errors", I noticed this piece of code, that came from
> 8ec6c8d7 (credential-cache: report more daemon connection errors,
> 2012-01-09):
> 
> 	if (send_request(socket, &buf) < 0) {
> 		if (errno != ENOENT && errno != ECONNREFUSED)
> 			die_errno("unable to connect to cache daemon");
> 		if (flags & FLAG_SPAWN) {
> 			spawn_daemon(socket);
> 			if (send_request(socket, &buf) < 0)
> 				die_errno("unable to connect to cache daemon");
> 		}
> 	}
> 
> What would happen when we get a resumable error and then weren't
> given the SPAWN flag?  It seems that do_cache() simply returns
> without dying.  Shouldn't we get "unable to connect" in such a case?

It's subtle, but I think we end up doing the right thing. Those errors aren't just "resumable"; they are "we do not have a daemon to talk to at all".

The "exit", "get", and "erase" operations do not pass the SPAWN flag. But if there is no daemon, they are all noops.

The "store" operation is the only one which uses SPAWN, and of course there we want to spin up a daemon so that we can put something in it.

It may be that SPAWN could have a better name to make this more clear.
Show 22 quoted lines
> diff --git c/builtin/credential-cache.c w/builtin/credential-cache.c
> index 78c02ad531..a41a17e58f 100644
> --- c/builtin/credential-cache.c
> +++ w/builtin/credential-cache.c
> @@ -101,13 +101,11 @@ static void do_cache(const char *socket, const char *action, int timeout,
>  	}
>  
>  	if (send_request(socket, &buf) < 0) {
> -		if (connection_fatally_broken(errno))
> +		if (connection_fatally_broken(errno) && !(flag & FLAG_SPAWN))
> +			die_errno("unable to connect to cache daemon");
> +		spawn_daemon(socket);
> +		if (send_request(socket, &buf) < 0)
>  			die_errno("unable to connect to cache daemon");
> -		if (flags & FLAG_SPAWN) {
> -			spawn_daemon(socket);
> -			if (send_request(socket, &buf) < 0)
> -				die_errno("unable to connect to cache daemon");
> -		}
>  	}
>  	strbuf_release(&buf);
>  }

If you do this, then I think we'll start producing spurious errors during normal use of the helper. Most interaction will generally start with a "get" request to the helpers. So if you don't have anything cached and the daemon stopped running, right now we just don't return a credential. With this we'd complain "unable to connect to daemon".

And then of course we'd follow that up by asking for the credential and spinning up a daemon to store it. But that first request after the daemon times out will always say "unable to connect".

-Peff
Previous: Junio C HamanoNext: Carlo Marcelo Arenas Belón
Message 25 of 27 in “windows: allow building without NO_UNIX_SOCKETS”
  1. 0/3 windows: allow building without NO_UNIX_SOCKETSCarlo Marcelo Arenas Belón, Sep 12, 2021
  2. 1/3 t0301: fixes for windows compatibilityCarlo Marcelo Arenas Belón, Sep 12, 2021
  3. Junio C HamanoSep 13, 2021
  4. Bagas SanjayaSep 13, 2021
  5. Carlo ArenasSep 13, 2021
  6. Junio C HamanoSep 13, 2021
  7. 3/3 git-compat-util: include declaration for unix socketsCarlo Marcelo Arenas Belón, Sep 12, 2021
  8. 2/3 credential-cache: check for windows specific errorsCarlo Marcelo Arenas Belón, Sep 12, 2021
  9. Junio C HamanoSep 13, 2021
  10. 0/3 windows: allow building without NO_UNIX_SOCKETSCarlo Marcelo Arenas Belón, Sep 13, 2021
  11. 1/3 t0301: fixes for windows compatibilityCarlo Marcelo Arenas Belón, Sep 13, 2021
  12. Johannes SchindelinSep 13, 2021
  13. Junio C HamanoSep 13, 2021
  14. 2/3 credential-cache: check for windows specific errorsCarlo Marcelo Arenas Belón, Sep 13, 2021
  15. Johannes SchindelinSep 13, 2021
  16. 3/3 git-compat-util: include declaration for unix socketsCarlo Marcelo Arenas Belón, Sep 13, 2021
  17. Johannes SchindelinSep 13, 2021
  18. Johannes SchindelinSep 13, 2021
  19. 0/3 windows: allow building without NO_UNIX_SOCKETSCarlo Marcelo Arenas Belón, Sep 14, 2021
  20. 1/3 t0301: fixes for windows compatibilityCarlo Marcelo Arenas Belón, Sep 14, 2021
  21. Ævar Arnfjörð BjarmasonNov 2, 2021
  22. 2/3 credential-cache: check for windows specific errorsCarlo Marcelo Arenas Belón, Sep 14, 2021
  23. Junio C HamanoSep 14, 2021
  24. What should happen in credential-cache on recoverable error without SPAWN option?Junio C Hamano, Sep 14, 2021
  25. Jeff KingSep 14, 2021
  26. 3/3 git-compat-util: include declaration for unix sockets in windowsCarlo Marcelo Arenas Belón, Sep 14, 2021
  27. Junio C HamanoSep 14, 2021

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.