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

Re: [PATCH v2] lockfile: add PID file for debugging stale locks

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 18, 2025, 00:32 UTC
Message-ID
<xmqqh5tozl1i.fsf@gitster.g>
In-Reply-To
<pull.2011.v2.git.1765997966593.gitgitgadget@gmail.com>
"Paulo Casaretto via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 21 quoted lines
>  /* Make sure errno contains a meaningful value on error */
>  static int lock_file(struct lock_file *lk, const char *path, int flags,
> -		     int mode)
> +		     int mode, enum lockfile_pid_component component)
> ...
>  }
>  
> @@ -102,7 +203,8 @@ static int lock_file(struct lock_file *lk, const char *path, int flags,
>   * exactly once. If timeout_ms is -1, try indefinitely.
>   */
>  static int lock_file_timeout(struct lock_file *lk, const char *path,
> -			     int flags, long timeout_ms, int mode)
> +			     int flags, long timeout_ms, int mode,
> +			     enum lockfile_pid_component component)
>  {
> ...
>  	if (timeout_ms == 0)
> -		return lock_file(lk, path, flags, mode);
> +		return lock_file(lk, path, flags, mode, component);
> -		fd = lock_file(lk, path, flags, mode);
> +		fd = lock_file(lk, path, flags, mode, component);

These are OK, but I expected these are rolled into an "unsigned flags" word, so that ...

Show 6 quoted lines
>  int hold_lock_file_for_update_timeout_mode(
> -		struct lock_file *lk, const char *path,
> -		int flags, long timeout_ms, int mode);
> +	struct lock_file *lk, const char *path,
> +	int flags, long timeout_ms, int mode,
> +	enum lockfile_pid_component component);

... things like this can be done without adding an extra parameter. Compared to "what should we do when we see an error?", ...

> -	fd = hold_lock_file_for_update_timeout(&lock, path.buf, LOCK_DIE_ON_ERROR, -1);
> +	fd = hold_lock_file_for_update_timeout(&lock, path.buf, LOCK_DIE_ON_ERROR, -1,
> +					       LOCKFILE_PID_OTHER);

... "how would we name the lockfile for this action?" is *not* all that special and should not occupy a separate parameter on its own.

Existing "flags" argument being "int" not "unsigned int" is a historical mistake, by the way.

But maybe it is just me?  I dunno.
Previous: Paulo Casaretto via GitGitGadgetNext: Junio C Hamano
Message 12 of 36 in “lockfile: add PID file for debugging stale locks”
  1. lockfile: add PID file for debugging stale locksPaulo Casaretto via GitGitGadget, Dec 2, 2025
  2. D. Ben KnobleDec 2, 2025
  3. Torsten BögershausenDec 3, 2025
  4. Jeff KingDec 3, 2025
  5. Junio C HamanoDec 3, 2025
  6. Jeff KingDec 3, 2025
  7. Taylor BlauDec 3, 2025
  8. Patrick SteinhardtDec 5, 2025
  9. Jeff KingDec 5, 2025
  10. Taylor BlauDec 3, 2025
  11. lockfile: add PID file for debugging stale locksPaulo Casaretto via GitGitGadget, Dec 17, 2025
  12. Junio C HamanoDec 18, 2025
  13. Junio C HamanoDec 18, 2025
  14. Junio C HamanoDec 18, 2025
  15. Ben KnobleDec 18, 2025
  16. Patrick SteinhardtDec 18, 2025
  17. lockfile: add PID file for debugging stale locksPaulo Casaretto via GitGitGadget, Dec 24, 2025
  18. Junio C HamanoDec 25, 2025
  19. Jeff KingDec 27, 2025
  20. Patrick SteinhardtJan 5, 2026
  21. lockfile: add PID file for debugging stale locksPaulo Casaretto via GitGitGadget, Jan 7, 2026
  22. Junio C HamanoJan 8, 2026
  23. D. Ben KnobleJan 8, 2026
  24. lockfile: add PID file for debugging stale locksPaulo Casaretto via GitGitGadget, Jan 20, 2026
  25. Junio C HamanoJan 20, 2026
  26. Jeff KingJan 21, 2026
  27. Eric SunshineJan 21, 2026
  28. Johannes SixtJan 21, 2026
  29. Jeff KingJan 21, 2026
  30. Junio C HamanoJan 21, 2026
  31. Jeff KingJan 21, 2026
  32. Junio C HamanoJan 21, 2026
  33. lockfile: add PID file for debugging stale locksPaulo Casaretto via GitGitGadget, Jan 22, 2026
  34. Junio C HamanoJan 22, 2026
  35. Patrick SteinhardtFeb 6, 2026
  36. Junio C HamanoFeb 6, 2026

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.