Re: [PATCH v5 08/35] lock_file(): always add lock_file object to lock_file_list
- From
Torsten Bögershausen <tboegi@web.de>
- Date
- Sep 18, 2014, 04:32 UTC
- Message-ID
- <541A6047.6000707@web.de>
- In-Reply-To
- <1410896036-12750-9-git-send-email-mhagger@alum.mit.edu>
On 09/16/2014 09:33 PM, Michael Haggerty wrote: []
Show 21 quoted lines
>
> diff --git a/lockfile.c b/lockfile.c
> index 983c3ec..00c972c 100644
> --- a/lockfile.c
> +++ b/lockfile.c
> @@ -129,6 +129,22 @@ static int lock_file(struct lock_file *lk, const char *path, int flags)
> */
> static const size_t max_path_len = sizeof(lk->filename) - 5;
>
> + if (!lock_file_list) {
> + /* One-time initialization */
> + sigchain_push_common(remove_lock_file_on_signal);
> + atexit(remove_lock_file);
> + }
> +
> + if (!lk->on_list) {
> + /* Initialize *lk and add it to lock_file_list: */
> + lk->fd = -1;
> + lk->owner = 0;
> + lk->on_list = 1;
> + lk->filename[0] = 0;Does it makes sense to change the order here:
Do the full initialization, and once that is completed, set on_list = 1 + lk->filename[0] = 0; + lk->on_list = 1;