Thread (3 messages) flat view 3 messages, 2 authors, 2016-06-15

RE: [PATCH] Prefer sysconf(_SC_OPEN_MAX) over getrlimit(RLIMIT_NOFILE,...)

From: Joachim Schmitz <hidden>
Date: 2016-06-15 22:54:33

Possibly related (same subject, not in this thread)

From: Junio C Hamano [mailto:gitster@pobox.com]
Sent: Wednesday, August 22, 2012 7:23 PM
To: Joachim Schmitz
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Prefer sysconf(_SC_OPEN_MAX) over
getrlimit(RLIMIT_NOFILE,...)

"Joachim Schmitz" [off-list ref] writes:
quoted
Signed-off-by: Joachim Schmitz <redacted>
---
 sha1_file.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/sha1_file.c b/sha1_file.c index af5cfbd..76714ad 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -747,6 +747,9 @@ static int open_packed_git_1(struct packed_git *p)
                return error("packfile %s index unavailable",
p->pack_name);

        if (!pack_max_fds) {
+#ifdef _SC_OPEN_MAX
+               unsigned int max_fds = sysconf(_SC_OPEN_MAX); #else
                struct rlimit lim;
                unsigned int max_fds;
@@ -754,6 +757,7 @@ static int open_packed_git_1(struct packed_git *p)
                        die_errno("cannot get RLIMIT_NOFILE");

                max_fds = lim.rlim_cur;
+#endif

                /* Save 3 for stdin/stdout/stderr, 22 for work */
                if (25 < max_fds)
--
1.7.12
Looks sane but it would be more readable to make this a small helper
function,
so that we do not need to have #ifdef/#endif in the primary flow of the
code.

Hmm, in compat/? Worth the effort fort hat single occrence?
By the way, I noticed that you seem to be sending patches out of git,
instead of
"diff -ru", which is a good sign ;-).  
Not quite, I'm generating them with "git format-patch origin", on the
NonStop machine, but can't send email from there (a) behind a firewall and
b) no email client available), so I copy/paste the resulting file into
Outlook.
But all of your patches are whitespace
damaged and cannot be applied X-<.
May well be Outlooks fault? How to solve?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help