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 tbo...@web.de 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

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 tbo...@web.de writes: Thanks for an interesting reading, please allow a side question: Could it be, that -1 == unlimited is Linux specific? And therefore not 100%

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 p...@peff.net 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-19 Thread Junio C Hamano
Torsten Bögershausen tbo...@web.de 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-18 Thread Junio C Hamano
Joey Hess j...@kitenet.net 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

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
Jeff King p...@peff.net 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

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 it

Re: RLIMIT_NOFILE fallback

2013-12-18 Thread Junio C Hamano
Junio C Hamano gits...@pobox.com writes: Jeff King p...@peff.net 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

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)) return

Re: RLIMIT_NOFILE fallback

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

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 p...@peff.net 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