|
|
@@ -9778,22 +9778,34 @@ static void raise_fd_limits(void)
|
|
|
#ifdef HAVE_SETRLIMIT
|
|
|
struct rlimit fdlimit;
|
|
|
unsigned long old_soft_limit;
|
|
|
+ char frombuf[0x10] = "unlimited";
|
|
|
+ char hardbuf[0x10] = "unlimited";
|
|
|
|
|
|
if (getrlimit(RLIMIT_NOFILE, &fdlimit))
|
|
|
applogr(, LOG_DEBUG, "setrlimit: Failed to getrlimit(RLIMIT_NOFILE)");
|
|
|
|
|
|
- if (fdlimit.rlim_cur == RLIM_INFINITY)
|
|
|
- applogr(, LOG_DEBUG, "setrlimit: Soft fd limit already infinite");
|
|
|
+ old_soft_limit = fdlimit.rlim_cur;
|
|
|
|
|
|
- if (fdlimit.rlim_cur == fdlimit.rlim_max)
|
|
|
- applogr(, LOG_DEBUG, "setrlimit: Soft fd limit already identical to hard limit (%lu)", (unsigned long)fdlimit.rlim_max);
|
|
|
+ if (fdlimit.rlim_max > FD_SETSIZE || fdlimit.rlim_max == RLIM_INFINITY)
|
|
|
+ fdlimit.rlim_cur = FD_SETSIZE;
|
|
|
+ else
|
|
|
+ fdlimit.rlim_cur = fdlimit.rlim_max;
|
|
|
+
|
|
|
+ if (fdlimit.rlim_max != RLIM_INFINITY)
|
|
|
+ snprintf(hardbuf, sizeof(hardbuf), "%lu", (unsigned long)fdlimit.rlim_max);
|
|
|
+ if (old_soft_limit != RLIM_INFINITY)
|
|
|
+ snprintf(frombuf, sizeof(frombuf), "%lu", old_soft_limit);
|
|
|
+
|
|
|
+ if (fdlimit.rlim_cur == old_soft_limit)
|
|
|
+ applogr(, LOG_DEBUG, "setrlimit: Soft fd limit not being changed from %lu (FD_SETSIZE=%lu; hard limit=%s)",
|
|
|
+ old_soft_limit, (unsigned long)FD_SETSIZE, hardbuf);
|
|
|
|
|
|
- old_soft_limit = fdlimit.rlim_cur;
|
|
|
- fdlimit.rlim_cur = fdlimit.rlim_max;
|
|
|
if (setrlimit(RLIMIT_NOFILE, &fdlimit))
|
|
|
- applogr(, LOG_DEBUG, "setrlimit: Failed to increase soft fd limit from %lu to hard limit of %lu", old_soft_limit, (unsigned long)fdlimit.rlim_max);
|
|
|
+ applogr(, LOG_DEBUG, "setrlimit: Failed to change soft fd limit from %s to %lu (FD_SETSIZE=%lu; hard limit=%s)",
|
|
|
+ frombuf, (unsigned long)fdlimit.rlim_cur, (unsigned long)FD_SETSIZE, hardbuf);
|
|
|
|
|
|
- applog(LOG_DEBUG, "setrlimit: Increased soft fd limit from %lu to hard limit of %lu", old_soft_limit, (unsigned long)fdlimit.rlim_max);
|
|
|
+ applog(LOG_DEBUG, "setrlimit: Changed soft fd limit from %s to %lu (FD_SETSIZE=%lu; hard limit=%s)",
|
|
|
+ frombuf, (unsigned long)fdlimit.rlim_cur, (unsigned long)FD_SETSIZE, hardbuf);
|
|
|
#else
|
|
|
applog(LOG_DEBUG, "setrlimit: Not supported by platform");
|
|
|
#endif
|