|
|
@@ -8257,6 +8257,32 @@ static void probe_pools(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static void raise_fd_limits(void)
|
|
|
+{
|
|
|
+#ifdef HAVE_SETRLIMIT
|
|
|
+ struct rlimit fdlimit;
|
|
|
+ unsigned long old_soft_limit;
|
|
|
+
|
|
|
+ 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");
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ applog(LOG_DEBUG, "setrlimit: Increased soft fd limit from %lu to hard limit of %lu", old_soft_limit, (unsigned long)fdlimit.rlim_max);
|
|
|
+#else
|
|
|
+ applog(LOG_DEBUG, "setrlimit: Not supported by platform");
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
int main(int argc, char *argv[])
|
|
|
{
|
|
|
struct sigaction handler;
|
|
|
@@ -8395,6 +8421,8 @@ int main(int argc, char *argv[])
|
|
|
applog(LOG_DEBUG, "pthread_cancel workaround in use");
|
|
|
#endif
|
|
|
|
|
|
+ raise_fd_limits();
|
|
|
+
|
|
|
if (opt_benchmark) {
|
|
|
struct pool *pool;
|
|
|
|