* [PATCH] gc: notice gc processes run by other users
@ 2013-12-31 12:07 Kyle J. McKay
2013-12-31 13:46 ` Duy Nguyen
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Kyle J. McKay @ 2013-12-31 12:07 UTC (permalink / raw)
To: Junio C Hamano, Nguyễn Thái Ngọc Duy; +Cc: git
Since 64a99eb4 git gc refuses to run without the --force option if
another gc process on the same repository is already running.
However, if the repository is shared and user A runs git gc on the
repository and while that gc is still running user B runs git gc on
the same repository the gc process run by user A will not be noticed
and the gc run by user B will go ahead and run.
The problem is that the kill(pid, 0) test fails with an EPERM error
since user B is not allowed to signal processes owned by user A
(unless user B is root).
Update the test to recognize an EPERM error as meaning the process
exists and another gc should not be run (unless --force is given).
---
I suggest this be included in maint as others may also have expected the
shared repository, different user gc scenario to be caught by the new
code when in fact it's not without this patch.
builtin/gc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/gc.c b/builtin/gc.c
index c14190f8..25f2237c 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -222,7 +222,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
time(NULL) - st.st_mtime <= 12 * 3600 &&
fscanf(fp, "%"PRIuMAX" %127c", &pid, locking_host) == 2 &&
/* be gentle to concurrent "gc" on remote hosts */
- (strcmp(locking_host, my_host) || !kill(pid, 0));
+ (strcmp(locking_host, my_host) || !kill(pid, 0) || errno == EPERM);
if (fp != NULL)
fclose(fp);
if (should_exit) {
--
1.8.5.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] gc: notice gc processes run by other users
2013-12-31 12:07 [PATCH] gc: notice gc processes run by other users Kyle J. McKay
@ 2013-12-31 13:46 ` Duy Nguyen
2013-12-31 20:35 ` Thiago Farina
2014-01-03 0:11 ` Kyle
2 siblings, 0 replies; 5+ messages in thread
From: Duy Nguyen @ 2013-12-31 13:46 UTC (permalink / raw)
To: Kyle J. McKay; +Cc: Junio C Hamano, Git Mailing List
On Tue, Dec 31, 2013 at 7:07 PM, Kyle J. McKay <mackyle@gmail.com> wrote:
> Since 64a99eb4 git gc refuses to run without the --force option if
> another gc process on the same repository is already running.
>
> However, if the repository is shared and user A runs git gc on the
> repository and while that gc is still running user B runs git gc on
> the same repository the gc process run by user A will not be noticed
> and the gc run by user B will go ahead and run.
>
> The problem is that the kill(pid, 0) test fails with an EPERM error
> since user B is not allowed to signal processes owned by user A
> (unless user B is root).
>
> Update the test to recognize an EPERM error as meaning the process
> exists and another gc should not be run (unless --force is given).
Ack. Looking at kill(2) the other errors are EINVAL and ESRCH, which
are fine to ignore.
> ---
>
> I suggest this be included in maint as others may also have expected the
> shared repository, different user gc scenario to be caught by the new
> code when in fact it's not without this patch.
>
> builtin/gc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/gc.c b/builtin/gc.c
> index c14190f8..25f2237c 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -222,7 +222,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
> time(NULL) - st.st_mtime <= 12 * 3600 &&
> fscanf(fp, "%"PRIuMAX" %127c", &pid, locking_host) == 2 &&
> /* be gentle to concurrent "gc" on remote hosts */
> - (strcmp(locking_host, my_host) || !kill(pid, 0));
> + (strcmp(locking_host, my_host) || !kill(pid, 0) || errno == EPERM);
> if (fp != NULL)
> fclose(fp);
> if (should_exit) {
> --
> 1.8.5.2
>
--
Duy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gc: notice gc processes run by other users
2013-12-31 12:07 [PATCH] gc: notice gc processes run by other users Kyle J. McKay
2013-12-31 13:46 ` Duy Nguyen
@ 2013-12-31 20:35 ` Thiago Farina
2014-01-03 0:11 ` Kyle
2 siblings, 0 replies; 5+ messages in thread
From: Thiago Farina @ 2013-12-31 20:35 UTC (permalink / raw)
To: Kyle J. McKay
Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy,
Git Mailing List
On Tue, Dec 31, 2013 at 10:07 AM, Kyle J. McKay <mackyle@gmail.com> wrote:
> Since 64a99eb4 git gc refuses to run without the --force option if
> another gc process on the same repository is already running.
>
> However, if the repository is shared and user A runs git gc on the
> repository and while that gc is still running user B runs git gc on
> the same repository the gc process run by user A will not be noticed
> and the gc run by user B will go ahead and run.
>
> The problem is that the kill(pid, 0) test fails with an EPERM error
> since user B is not allowed to signal processes owned by user A
> (unless user B is root).
>
> Update the test to recognize an EPERM error as meaning the process
> exists and another gc should not be run (unless --force is given).
Looks like you are missing your Signed-off-by: line.
--
Thiago Farina
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gc: notice gc processes run by other users
2013-12-31 12:07 [PATCH] gc: notice gc processes run by other users Kyle J. McKay
2013-12-31 13:46 ` Duy Nguyen
2013-12-31 20:35 ` Thiago Farina
@ 2014-01-03 0:11 ` Kyle
2014-01-03 0:15 ` Junio C Hamano
2 siblings, 1 reply; 5+ messages in thread
From: Kyle @ 2014-01-03 0:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Nguyễn Thái Ngọc Duy, Git Mailing List
On Dec 31, 2013, at 04:07, Kyle J. McKay wrote:
> Since 64a99eb4 git gc refuses to run without the --force option if
> another gc process on the same repository is already running.
>
> However, if the repository is shared and user A runs git gc on the
> repository and while that gc is still running user B runs git gc on
> the same repository the gc process run by user A will not be noticed
> and the gc run by user B will go ahead and run.
>
> The problem is that the kill(pid, 0) test fails with an EPERM error
> since user B is not allowed to signal processes owned by user A
> (unless user B is root).
>
> Update the test to recognize an EPERM error as meaning the process
> exists and another gc should not be run (unless --force is given).
Oops, sorry, forgot sign off, here's my sign off:
Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
> ---
>
> I suggest this be included in maint as others may also have expected
> the
> shared repository, different user gc scenario to be caught by the new
> code when in fact it's not without this patch.
>
> builtin/gc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/gc.c b/builtin/gc.c
> index c14190f8..25f2237c 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -222,7 +222,7 @@ static const char *lock_repo_for_gc(int force,
> pid_t* ret_pid)
> time(NULL) - st.st_mtime <= 12 * 3600 &&
> fscanf(fp, "%"PRIuMAX" %127c", &pid, locking_host) == 2 &&
> /* be gentle to concurrent "gc" on remote hosts */
> - (strcmp(locking_host, my_host) || !kill(pid, 0));
> + (strcmp(locking_host, my_host) || !kill(pid, 0) || errno ==
> EPERM);
> if (fp != NULL)
> fclose(fp);
> if (should_exit) {
> --
> 1.8.5.2
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gc: notice gc processes run by other users
2014-01-03 0:11 ` Kyle
@ 2014-01-03 0:15 ` Junio C Hamano
0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2014-01-03 0:15 UTC (permalink / raw)
To: Kyle; +Cc: Nguyễn Thái Ngọc Duy, Git Mailing List
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-01-03 0:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-31 12:07 [PATCH] gc: notice gc processes run by other users Kyle J. McKay
2013-12-31 13:46 ` Duy Nguyen
2013-12-31 20:35 ` Thiago Farina
2014-01-03 0:11 ` Kyle
2014-01-03 0:15 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox