git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 22, 2012, 17:23 UTC
Message-ID
<7v4nnualjf.fsf@alter.siamese.dyndns.org>
In-Reply-To
<002301cd807f$4e19ad80$ea4d0880$@schmitz-digital.de>
"Joachim Schmitz" <jojo@schmitz-digital.de> writes:
Show 29 quoted lines
> Signed-off-by: Joachim Schmitz <jojo@schmitz-digital.de>
> ---
>  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.

By the way, I noticed that you seem to be sending patches out of git, instead of "diff -ru", which is a good sign ;-). But all of your patches are whitespace damaged and cannot be applied X-<.

Previous: Joachim SchmitzNext: Joachim Schmitz
Message 2 of 5 in “Prefer sysconf(_SC_OPEN_MAX) over getrlimit(RLIMIT_NOFILE,...)”
  1. Prefer sysconf(_SC_OPEN_MAX) over getrlimit(RLIMIT_NOFILE,...)Joachim Schmitz, Aug 22, 2012
  2. Junio C HamanoAug 22, 2012
  3. Joachim SchmitzAug 22, 2012
  4. Junio C HamanoAug 22, 2012
  5. Joachim SchmitzAug 22, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.