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

Re: [PATCH 1/3] fdopen_lock_file(): access a lockfile using stdio

From
Torsten Bögershausen <tboegi@web.de>
Date
Oct 2, 2014, 09:29 UTC
Message-ID
<542D1AF2.8050508@web.de>
In-Reply-To
<1412162089-3233-2-git-send-email-mhagger@alum.mit.edu>

On 01.10.14 13:14, Michael Haggerty wrote: [] Nice done, small comments inline

Show 10 quoted lines
> diff --git a/lockfile.c b/lockfile.c
> index d27e61c..e046027 100644
> --- a/lockfile.c
> +++ b/lockfile.c
> @@ -7,20 +7,29 @@
>  
>  static struct lock_file *volatile lock_file_list;
>  
> -static void remove_lock_files(void)
> +static void remove_lock_files(int skip_fclose)

Even if the motivation to skip is clear now and here, I would consider to do it the other way around, and actively order the fclose():

static void remove_lock_files(int call_fclose)
Show 18 quoted lines
>  {
>  	pid_t me = getpid();
>  
>  	while (lock_file_list) {
> -		if (lock_file_list->owner == me)
> +		if (lock_file_list->owner == me) {
> +			/* fclose() is not safe to call in a signal handler */
> +			if (skip_fclose)
> +				lock_file_list->fp = NULL;
>  			rollback_lock_file(lock_file_list);
> +		}
>  		lock_file_list = lock_file_list->next;
>  	}
>  }
>  
> +static void remove_lock_files_on_exit(void)
> +{
> +	remove_lock_files(0);
What does "0" mean ?
remove_lock_files(LK_DO_FCLOSE) ?
Show 6 quoted lines
> +}
> +
>  static void remove_lock_files_on_signal(int signo)
>  {
> -	remove_lock_files();
> +	remove_lock_files(1);
And what does this "1" mean ?
remove_lock_files(LK_SKIP_FCLOSE) ?
We can even have an emum, or use #define
>
Previous: Junio C HamanoNext: Michael Haggerty
Message 5 of 9 in “Support stdio access to lockfiles”
  1. 0/3 Support stdio access to lockfilesMichael Haggerty, Oct 1, 2014
  2. 1/3 fdopen_lock_file(): access a lockfile using stdioMichael Haggerty, Oct 1, 2014
  3. Jeff KingOct 1, 2014
  4. Junio C HamanoOct 1, 2014
  5. Torsten BögershausenOct 2, 2014
  6. Michael HaggertyOct 12, 2014
  7. 2/3 dump_marks(): reimplement using fdopen_lock_file()Michael Haggerty, Oct 1, 2014
  8. 3/3 commit_packed_refs(): reimplement using fdopen_lock_file()Michael Haggerty, Oct 1, 2014
  9. Jeff KingOct 1, 2014

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.