Commit cc8c78aa authored by Petr Špaček's avatar Petr Špaček

Merge branch 'setrlimit' into 'master'

file-descriptor count limit

See merge request !876
parents 13c9ff79 6b0449a9
Pipeline #53811 passed with stage
in 34 seconds
Knot Resolver ??
================================
Improvements
------------
- increase file-descriptor count limit to maximum allowed value (hard limit)
Knot Resolver 4.2.2 (2019-10-07)
================================
......
......@@ -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);
......
......@@ -13,6 +13,7 @@ User=@user@
TimeoutStopSec=10s
WatchdogSec=10s
Restart=on-abnormal
LimitNOFILE=1048576
Sockets=kresd.socket
Sockets=kresd-tls.socket
Sockets=kresd-control@%i.socket
......
......@@ -12,6 +12,7 @@ ExecStart=@sbin_dir@/kresd --config=@etc_dir@/kresd.conf --forks=1
TimeoutStopSec=10s
WatchdogSec=10s
Restart=on-abnormal
LimitNOFILE=1048576
[Install]
WantedBy=kresd.target
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