Commit 6b0449a9 authored by Vladimír Čunát's avatar Vladimír Čunát Committed by Petr Špaček

daemon/main: file-descriptor count limit: soft->hard

parent 77fe2767
Pipeline #53810 passed with stages
in 44 minutes and 37 seconds
......@@ -3,10 +3,10 @@ Knot Resolver ??
Improvements
------------
- increase file-descriptor count limits to 1M by default
- increase file-descriptor count limit to maximum allowed value (hard limit)
Knot Resolver 4.2.2 (2019-10-dd)
Knot Resolver 4.2.2 (2019-10-07)
================================
Bugfixes
......
......@@ -37,6 +37,7 @@
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sys/resource.h>
#include <unistd.h>
#include <lua.h>
......@@ -740,6 +741,23 @@ int main(int argc, char **argv)
args.config = "config";
}
/* File-descriptor count limit: soft->hard. */
struct rlimit rlim;
ret = getrlimit(RLIMIT_NOFILE, &rlim);
if (ret == 0 && rlim.rlim_cur != rlim.rlim_max) {
kr_log_verbose("[system] increasing file-descriptor limit: %ld -> %ld\n",
(long)rlim.rlim_cur, (long)rlim.rlim_max);
rlim.rlim_cur = rlim.rlim_max;
ret = setrlimit(RLIMIT_NOFILE, &rlim);
}
if (ret) {
kr_log_error("[system] failed to get or set file-descriptor limit: %s\n",
strerror(errno));
} else if (rlim.rlim_cur < 1024*1024) {
kr_log_info("[system] warning: hard limit for number of file-descriptors is only %ld but recommended value is 1048576\n",
rlim.rlim_cur);
}
/* Connect forks with local socket */
fd_array_t ipc_set;
array_init(ipc_set);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment