git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* Re: Re: [PATCH] maintenance: fix two memory leaks
@ 2021-05-10 11:47 Оксана Алексеева
  0 siblings, 0 replies; 2+ messages in thread
From: Оксана Алексеева @ 2021-05-10 11:47 UTC (permalink / raw)
  To: lilinchao; +Cc: dstolee, git, gitster, lenaic, sunshine



Отправлено с iPhone

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Re: [PATCH] maintenance: fix two memory leaks
       [not found]   ` <0c04f7c2b15f11eb82baa4badb2c2b1178978@pobox.com>
@ 2021-05-10  7:50     ` lilinchao
  0 siblings, 0 replies; 2+ messages in thread
From: lilinchao @ 2021-05-10  7:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Lénaïc Huard, git, Derrick Stolee, Eric Sunshine

>"lilinchao@oschina.cn" <lilinchao@oschina.cn> writes:
>
>>>@@ -1999,6 +2000,7 @@ static int update_background_schedule(int enable)
>>> die("unknown background scheduler: %s", scheduler);
>>>
>>> rollback_lock_file(&lk);
>>>+	free(lock_path);
>> Based on your change, I think when "hold_lock_file_for_update()<0", we should also free local_path
>> Thanks
>
>Meaning something like this?
>
>
> builtin/gc.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
>diff --git c/builtin/gc.c w/builtin/gc.c
>index 98a803196b..50565c37c7 100644
>--- c/builtin/gc.c
>+++ w/builtin/gc.c
>@@ -1971,8 +1971,10 @@ static int update_background_schedule(int enable)
> cmd = sep + 1;
> }
>
>-	if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0)
>-	return error(_("another process is scheduling background maintenance"));
>+	if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {
>+	result = error(_("another process is scheduling background maintenance"));
>+	goto cleanup;
>+	}
>
> if (!strcmp(scheduler, "launchctl"))
> result = launchctl_update_schedule(enable, get_lock_file_fd(&lk), cmd);
>@@ -1984,6 +1986,9 @@ static int update_background_schedule(int enable)
> die("unknown background scheduler: %s", scheduler);
>
> rollback_lock_file(&lk);
>+
>+cleanup:
>+	free(lock_path);
> free(testing);
> return result;
> }

Yes, it's almost like this, and your is better than I thought.
I just referred to this function(L1266-L1321): 

static int maintenance_run_tasks(struct maintenance_run_opts *opts)
{
        ...

if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {
                ...

free(lock_path);
return 0;
}
free(lock_path);

        ...
        ...

rollback_lock_file(&lk);
return result;
} 

and thought we should also apply it to "update_background_schedule()".



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-10 13:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 11:47 Re: [PATCH] maintenance: fix two memory leaks Оксана Алексеева
  -- strict thread matches above, loose matches on Subject: below --
2021-05-09 22:16 Lénaïc Huard
2021-05-10  6:38 ` lilinchao
     [not found]   ` <0c04f7c2b15f11eb82baa4badb2c2b1178978@pobox.com>
2021-05-10  7:50     ` lilinchao

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git