MCPcopy Create free account
hub / github.com/git/git / get_max_fd_limit

Function get_max_fd_limit

packfile.c:558–597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

556}
557
558static unsigned int get_max_fd_limit(void)
559{
560#ifdef RLIMIT_NOFILE
561 {
562 struct rlimit lim;
563
564 if (!getrlimit(RLIMIT_NOFILE, &lim))
565 return lim.rlim_cur;
566 }
567#endif
568
569#ifdef _SC_OPEN_MAX
570 {
571 long open_max = sysconf(_SC_OPEN_MAX);
572 if (0 < open_max)
573 return open_max;
574 /*
575 * Otherwise, we got -1 for one of the two
576 * reasons:
577 *
578 * (1) sysconf() did not understand _SC_OPEN_MAX
579 * and signaled an error with -1; or
580 * (2) sysconf() said there is no limit.
581 *
582 * We _could_ clear errno before calling sysconf() to
583 * tell these two cases apart and return a huge number
584 * in the latter case to let the caller cap it to a
585 * value that is not so selfish, but letting the
586 * fallback OPEN_MAX codepath take care of these cases
587 * is a lot simpler.
588 */
589 }
590#endif
591
592#ifdef OPEN_MAX
593 return OPEN_MAX;
594#else
595 return 1; /* see the caller ;-) */
596#endif
597}
598
599const char *pack_basename(struct packed_git *p)
600{

Callers 1

open_packed_git_1Function · 0.85

Calls 1

getrlimitFunction · 0.85

Tested by

no test coverage detected