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

Re: [PATCH 1/2] lockfile: allow file locking to be retried with a timeout

From
Junio C Hamano <gitster@pobox.com>
Date
May 11, 2015, 18:04 UTC
Message-ID
<xmqq38337zy1.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1430491977-25817-2-git-send-email-mhagger@alum.mit.edu>
Michael Haggerty <mhagger@alum.mit.edu> writes:
Show 26 quoted lines
> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
> ---
>
> Notes (discussion):
>     It would be easy to also add a hold_lock_file_for_append_timeout(),
>     but I can't yet think of an application for it.
>
>  lockfile.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  lockfile.h | 16 +++++++++++--
>  2 files changed, 91 insertions(+), 4 deletions(-)
>
> diff --git a/lockfile.c b/lockfile.c
> index 9889277..30e65e9 100644
> --- a/lockfile.c
> +++ b/lockfile.c
> @@ -157,6 +157,80 @@ static int lock_file(struct lock_file *lk, const char *path, int flags)
>  	return lk->fd;
>  }
>  
> +static int sleep_microseconds(long us)
> +{
> +	struct timeval tv;
> +	tv.tv_sec = 0;
> +	tv.tv_usec = us;
> +	return select(0, NULL, NULL, NULL, &tv);
> +}

This is familiar for an old timer like me. It seems help.c uses "poll(NULL, 0, timeout)" for "do nothing but wait" (and we have compat/poll to help those who lack poll() by using select()).

As we do not need microseconds resolution here, either would be fine ;-)

Previous: Michael HaggertyNext: Michael Haggerty
Message 3 of 18 in “Retry attempts to acquire the packed-refs lock”
  1. 0/2 Retry attempts to acquire the packed-refs lockMichael Haggerty, May 1, 2015
  2. 1/2 lockfile: allow file locking to be retried with a timeoutMichael Haggerty, May 1, 2015
  3. Junio C HamanoMay 11, 2015
  4. 2/2 lock_packed_refs(): allow retries when acquiring the packed-refs lockMichael Haggerty, May 1, 2015
  5. Johannes SixtMay 1, 2015
  6. Michael HaggertyMay 2, 2015
  7. Johannes SixtMay 2, 2015
  8. Michael HaggertyMay 11, 2015
  9. Stefan BellerMay 1, 2015
  10. Jeff KingMay 1, 2015
  11. Michael HaggertyMay 2, 2015
  12. Stefan BellerMay 4, 2015
  13. Jeff KingMay 5, 2015
  14. Michael HaggertyMay 11, 2015
  15. Jeff KingMay 11, 2015
  16. Stefan BellerMay 11, 2015
  17. Stefan BellerMay 11, 2015
  18. Junio C HamanoMay 3, 2015

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.