David Turner writes:
> If the writer has the smaller HOST_NAME_MAX, this will work fine. If the
> reader
> has the smaller HOST_NAME_MAX, and the writer's actual value is too long,
> then there's no way the strcmp would succeed anyway. So I don't think we need
> to
René Scharfe writes:
> How important is it to scan the whole file in one call? We could split
> it up like this and use a strbuf to handle host names of any length. We
> need to be permissive here to allow machines with different values for
> HOST_NAME_MAX to work with the same
Jeff King writes:
> I doubt that doing it in one call matters. It's not like stdio promises
> us any atomicity in the first place.
>
>> -fscanf(fp, "%"SCNuMAX" %127c", , locking_host) == 2
>> &&
>> +fscanf(fp, "%"SCNuMAX" ", ) == 1 &&
>> +
> -Original Message-
> From: René Scharfe [mailto:l@web.de]
> Sent: Tuesday, April 18, 2017 12:08 PM
> To: Junio C Hamano ; David Turner
...
> >> Of course, my_host is sized to HOST_NAME_MAX + 1 and we are comparing
> >> it with locking_host, so perhaps we'd need to
On Tue, Apr 18, 2017 at 06:07:43PM +0200, René Scharfe wrote:
> > - fscanf(fp, "%"SCNuMAX" %127c", , locking_host) == 2
> > &&
> > + fscanf(fp, scan_fmt, , locking_host) == 2 &&
> > /* be gentle to concurrent "gc" on remote hosts */
> >
Am 18.04.2017 um 03:41 schrieb Junio C Hamano:
> Junio C Hamano writes:
>
>> David Turner writes:
>>
>>> @@ -250,14 +250,14 @@ static const char *lock_repo_for_gc(int force, pid_t*
>>> ret_pid)
>>> ...
>>> if (!force) {
>>> - static char
Junio C Hamano writes:
> David Turner writes:
>
>> @@ -250,14 +250,14 @@ static const char *lock_repo_for_gc(int force, pid_t*
>> ret_pid)
>> ...
>> if (!force) {
>> -static char locking_host[128];
>> +static char
David Turner writes:
> @@ -250,14 +250,14 @@ static const char *lock_repo_for_gc(int force, pid_t*
> ret_pid)
> ...
> if (!force) {
> - static char locking_host[128];
> + static char locking_host[HOST_NAME_MAX + 1];
> int
If the full hostname doesn't fit in the buffer supplied to
gethostname, POSIX does not specify whether the buffer will be
null-terminated, so to be safe, we should do it ourselves. Introduce
new function, xgethostname, which ensures that there is always a \0
at the end of the buffer.
Always use
9 matches
Mail list logo