Re: RLIMIT_NOFILE fallback

2013-12-20 Thread Torsten Bögershausen
On 2013-12-20 10.12, Jeff King wrote: > On Thu, Dec 19, 2013 at 09:39:55AM -0800, Junio C Hamano wrote: > >> Torsten Bögershausen writes: >> >>> Thanks for an interesting reading, >>> please allow a side question: >>> Could it be, that "-1 == unlimited" is Linux specific? >>> And therefore not 10

Re: RLIMIT_NOFILE fallback

2013-12-20 Thread Jeff King
On Thu, Dec 19, 2013 at 09:39:55AM -0800, Junio C Hamano wrote: > Torsten Bögershausen writes: > > > Thanks for an interesting reading, > > please allow a side question: > > Could it be, that "-1 == unlimited" is Linux specific? > > And therefore not 100% portable ? > > > > And doesn't "unlimite

Re: RLIMIT_NOFILE fallback

2013-12-19 Thread Junio C Hamano
Torsten Bögershausen writes: > Thanks for an interesting reading, > please allow a side question: > Could it be, that "-1 == unlimited" is Linux specific? > And therefore not 100% portable ? > > And doesn't "unlimited" number of files call for trouble, > having the risk to starve the machine ? >

Re: RLIMIT_NOFILE fallback

2013-12-19 Thread Torsten Bögershausen
On 2013-12-19 01.15, Jeff King wrote: > On Wed, Dec 18, 2013 at 02:59:12PM -0800, Junio C Hamano wrote: > >> Jeff King writes: >> Yes, that is locally OK, but depending on how the caller behaves, we might need to have an extra saved_errno dance here, which I didn't want to get into

Re: RLIMIT_NOFILE fallback

2013-12-18 Thread Jeff King
On Wed, Dec 18, 2013 at 02:59:12PM -0800, Junio C Hamano wrote: > Jeff King writes: > > >> Yes, that is locally OK, but depending on how the caller behaves, we > >> might need to have an extra saved_errno dance here, which I didn't > >> want to get into... > > > > I think we are fine. The only ca

Re: RLIMIT_NOFILE fallback

2013-12-18 Thread Junio C Hamano
Jeff King writes: > On Wed, Dec 18, 2013 at 01:37:24PM -0800, Junio C Hamano wrote: > >> Jeff King writes: >> >> > According to the POSIX quote above, it sounds like we could do: >> > >> > #if defined (_SC_OPEN_MAX) >> > { >> > long max; >> > errno = 0; >> > ma

Re: RLIMIT_NOFILE fallback

2013-12-18 Thread Jeff King
On Wed, Dec 18, 2013 at 01:37:24PM -0800, Junio C Hamano wrote: > Jeff King writes: > > > According to the POSIX quote above, it sounds like we could do: > > > > #if defined (_SC_OPEN_MAX) > > { > > long max; > > errno = 0; > > max = sysconf(_SC_OPEN_MAX); > >

Re: RLIMIT_NOFILE fallback

2013-12-18 Thread Junio C Hamano
Jeff King writes: > According to the POSIX quote above, it sounds like we could do: > > #if defined (_SC_OPEN_MAX) > { > long max; > errno = 0; > max = sysconf(_SC_OPEN_MAX); > if (0 < max) /* got the limit */ > return max; >

Re: RLIMIT_NOFILE fallback

2013-12-18 Thread Jeff King
On Wed, Dec 18, 2013 at 11:50:24AM -0800, Junio C Hamano wrote: > 8< -- > > static unsigned int get_max_fd_limit(void) > { > #ifdef RLIMIT_NOFILE > struct rlimit lim; > > if (!getrlimit(RLIMIT_NOFILE, &lim)) >

Re: RLIMIT_NOFILE fallback

2013-12-18 Thread Junio C Hamano
Junio C Hamano writes: > Jeff King writes: > >> That is, does sysconf actually work on such a system (or does it need a >> similar run-time fallback)? And either way, we should try falling back >> to OPEN_MAX rather than 1 if we have it. > > Interesting. > >> As far as the warning, I am not sure

Re: RLIMIT_NOFILE fallback

2013-12-18 Thread Joey Hess
Jeff King wrote: > I wish we understood why getrlimit was failing. Returning EFAULT seems > like an odd choice if it is not implemented for the system. On such a > system, do the other fallbacks actually work? Would it work to do: > > That is, does sysconf actually work on such a system (or does i

Re: RLIMIT_NOFILE fallback

2013-12-18 Thread Junio C Hamano
Jeff King writes: > That is, does sysconf actually work on such a system (or does it need a > similar run-time fallback)? And either way, we should try falling back > to OPEN_MAX rather than 1 if we have it. Interesting. > As far as the warning, I am not sure I see a point. The user does not >

Re: RLIMIT_NOFILE fallback

2013-12-18 Thread Jeff King
On Wed, Dec 18, 2013 at 10:00:35AM -0800, Junio C Hamano wrote: > Joey Hess writes: > > > In sha1_file.c, when git is built on linux, it will use > > getrlimit(RLIMIT_NOFILE). I've been deploying git binaries to some > > unusual systems, like embedded NAS devices, and it seems some with older >

Re: RLIMIT_NOFILE fallback

2013-12-18 Thread Joey Hess
Junio C Hamano wrote: > Hmph, perhaps you are right. Like this? Works for me. -- see shy jo signature.asc Description: Digital signature

Re: RLIMIT_NOFILE fallback

2013-12-18 Thread Junio C Hamano
Joey Hess writes: > In sha1_file.c, when git is built on linux, it will use > getrlimit(RLIMIT_NOFILE). I've been deploying git binaries to some > unusual systems, like embedded NAS devices, and it seems some with older > kernels like 2.6.33 fail with "fatal: cannot get RLIMIT_NOFILE: Bad addres

RLIMIT_NOFILE fallback

2013-12-18 Thread Joey Hess
In sha1_file.c, when git is built on linux, it will use getrlimit(RLIMIT_NOFILE). I've been deploying git binaries to some unusual systems, like embedded NAS devices, and it seems some with older kernels like 2.6.33 fail with "fatal: cannot get RLIMIT_NOFILE: Bad address". I could work around thi