public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Joey Hess <joey@kitenet•net>
Cc: git@vger•kernel.org
Subject: Re: RLIMIT_NOFILE fallback
Date: Wed, 18 Dec 2013 10:00:35 -0800	[thread overview]
Message-ID: <xmqqy53ihwe4.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20131218171446.GA19657@kitenet.net> (Joey Hess's message of "Wed, 18 Dec 2013 13:14:46 -0400")

Joey Hess <joey@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 RLIMIT_NOFILE: Bad address".
>
> I could work around this by building git without RLIMIT_NOFILE defined,
> but perhaps it would make sense to improve the code to fall back
> to one of the other methods for getting the limit, and/or return the
> hardcoded 1 as a fallback. This would make git binaries more robust
> against old/broken/misconfigured kernels.

Hmph, perhaps you are right.  Like this?

 sha1_file.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index daacc0c..a3a0014 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -809,8 +809,12 @@ static unsigned int get_max_fd_limit(void)
 #ifdef RLIMIT_NOFILE
 	struct rlimit lim;
 
-	if (getrlimit(RLIMIT_NOFILE, &lim))
-		die_errno("cannot get RLIMIT_NOFILE");
+	if (getrlimit(RLIMIT_NOFILE, &lim)) {
+		static int warn_only_once;
+		if (!warn_only_once++)
+			warning("cannot get RLIMIT_NOFILE: %s", strerror(errno));
+		return 1; /* see the caller ;-) */
+	}
 
 	return lim.rlim_cur;
 #elif defined(_SC_OPEN_MAX)

  reply	other threads:[~2013-12-18 18:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18 17:14 RLIMIT_NOFILE fallback Joey Hess
2013-12-18 18:00 ` Junio C Hamano [this message]
2013-12-18 18:41   ` Joey Hess
2013-12-18 19:17   ` Jeff King
2013-12-18 19:50     ` Junio C Hamano
2013-12-18 20:18       ` Junio C Hamano
2013-12-18 21:28       ` Jeff King
2013-12-18 21:37         ` Junio C Hamano
2013-12-18 21:40           ` Jeff King
2013-12-18 22:59             ` Junio C Hamano
2013-12-19  0:15               ` Jeff King
2013-12-19 17:30                 ` Torsten Bögershausen
2013-12-19 17:39                   ` Junio C Hamano
2013-12-20  9:12                     ` Jeff King
2013-12-20 14:43                       ` Torsten Bögershausen
2013-12-18 20:03     ` Joey Hess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqy53ihwe4.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=joey@kitenet$(echo .)net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox