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, 18:07 UTC
Message-ID
<7vboi294xe.fsf@alter.siamese.dyndns.org>
In-Reply-To
<003b01cd808f$0a5bf610$1f13e230$@schmitz-digital.de>
"Joachim Schmitz" <jojo@schmitz-digital.de> writes:
Show 6 quoted lines
>> 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?

Compat/ is to have some systems that lack an interface we deem to be common on platforms emulate that interface, but in this case, we just want something like:

	static int get_max_fd_limit(void)
        {
        #ifdef _SC_OPEN_MAX
        	...
	#else
		...
	#endif
		return max_fds;
	}
and that is not emulating anybody's standard interface.

Such a helper before the definition of the function that your patch is touching, in the same file as a file-scope static, was what I meant. If other places in the code want to open tons of pipes or file descriptors for some reason, we may want to make it part of the supporting infrastructure, and drop "static " at the beginning and add "extern int get_max_fd_limit(void);" to cache.h for others to use, but as you said, there is currently only one place that uses it, so it can stay static to the file.

Previous: Joachim SchmitzNext: Joachim Schmitz
Message 4 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.