Re: [PATCH v3 1/2] use HOST_NAME_MAX to size buffers for gethostname(2)

2017-04-20 Thread Torsten Bögershausen
I think I meant to write "big pidfiles" there. With xsize_t() gc would die when seeing a pidfile whose size doesn't fit into size_t. The version I sent just ignores such files. However, it would choke on slightly smaller files that happen to not fit into memory. And no reasonable pidfile

Re: [PATCH v3 1/2] use HOST_NAME_MAX to size buffers for gethostname(2)

2017-04-20 Thread René Scharfe
Am 20.04.2017 um 20:37 schrieb Torsten Bögershausen: On 2017-04-19 22:02, René Scharfe wrote: Am 19.04.2017 um 21:09 schrieb Torsten Bögershausen: On 2017-04-19 19:28, René Scharfe wrote: [] One or two minor comments inline diff --git a/builtin/gc.c b/builtin/gc.c index 2daede7820..4c1c01e87d

Re: [PATCH v3 1/2] use HOST_NAME_MAX to size buffers for gethostname(2)

2017-04-20 Thread Torsten Bögershausen
On 2017-04-19 22:02, René Scharfe wrote: > Am 19.04.2017 um 21:09 schrieb Torsten Bögershausen: >> On 2017-04-19 19:28, René Scharfe wrote: >> [] >> One or two minor comments inline >>> diff --git a/builtin/gc.c b/builtin/gc.c >>> index 2daede7820..4c1c01e87d 100644 >>> --- a/builtin/gc.c >>> +++

Re: [PATCH v3 1/2] use HOST_NAME_MAX to size buffers for gethostname(2)

2017-04-19 Thread René Scharfe
Am 19.04.2017 um 21:09 schrieb Torsten Bögershausen: On 2017-04-19 19:28, René Scharfe wrote: [] One or two minor comments inline diff --git a/builtin/gc.c b/builtin/gc.c index 2daede7820..4c1c01e87d 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -228,21 +228,99 @@ static int need_to_gc(void)

Re: [PATCH v3 1/2] use HOST_NAME_MAX to size buffers for gethostname(2)

2017-04-19 Thread Torsten Bögershausen
On 2017-04-19 19:28, René Scharfe wrote: [] One or two minor comments inline > diff --git a/builtin/gc.c b/builtin/gc.c > index 2daede7820..4c1c01e87d 100644 > --- a/builtin/gc.c > +++ b/builtin/gc.c > @@ -228,21 +228,99 @@ static int need_to_gc(void) > return 1; > } > > +struct pidfile {

RE: [PATCH v3 1/2] use HOST_NAME_MAX to size buffers for gethostname(2)

2017-04-19 Thread David Turner
> I had another look at this last night and cooked up the following patch. > Might > have gone overboard with it.. > > -- >8 -- > Subject: [PATCH] gc: support arbitrary hostnames and pids in > lock_repo_for_gc() > > git gc writes its pid and hostname into a pidfile to prevent concurrent >

Re: [PATCH v3 1/2] use HOST_NAME_MAX to size buffers for gethostname(2)

2017-04-19 Thread René Scharfe
Am 19.04.2017 um 03:28 schrieb Jonathan Nieder: > David Turner wrote: >> @@ -274,7 +278,7 @@ static const char *lock_repo_for_gc(int force, pid_t* >> ret_pid) >> * running. >> */ >> time(NULL) - st.st_mtime <= 12 * 3600 && >> -

Re: [PATCH v3 1/2] use HOST_NAME_MAX to size buffers for gethostname(2)

2017-04-19 Thread René Scharfe
Am 19.04.2017 um 03:28 schrieb Jonathan Nieder: >> From: René Scharfe >> >> POSIX limits the length of host names to HOST_NAME_MAX. Export the >> fallback definition from daemon.c and use this constant to make all >> buffers used with gethostname(2) big enough for any possible

Re: [PATCH v3 1/2] use HOST_NAME_MAX to size buffers for gethostname(2)

2017-04-18 Thread Junio C Hamano
Jonathan Nieder writes: >> @@ -274,7 +278,7 @@ static const char *lock_repo_for_gc(int force, pid_t* >> ret_pid) >> * running. >> */ >> time(NULL) - st.st_mtime <= 12 * 3600 && >> -

Re: [PATCH v3 1/2] use HOST_NAME_MAX to size buffers for gethostname(2)

2017-04-18 Thread Jonathan Nieder
Hi, David Turner wrote: > From: René Scharfe > > POSIX limits the length of host names to HOST_NAME_MAX. Export the > fallback definition from daemon.c and use this constant to make all > buffers used with gethostname(2) big enough for any possible result > and a terminating NUL.