diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-04-14 10:43:16 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-04-14 10:43:16 +0200 |
commit | dfb88dae65fbdc37d72483ddff23171ef4070dae (patch) | |
tree | 387294ba81c2847a2f713be54750da20fb5bade2 /src/main.c | |
parent | 549d78e74c1140b1a4dcd35e44e64d51a3c613e6 (diff) | |
download | conntrack-tools-dfb88dae65fbdc37d72483ddff23171ef4070dae.tar.gz conntrack-tools-dfb88dae65fbdc37d72483ddff23171ef4070dae.zip |
conntrackd: change scheduler and priority via configuration file
With this patch, you can change the scheduler policy and priority
for conntrackd. Using a RT scheduler policy reduces the chances to
hit ENOBUFS in Netlink.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -26,6 +26,7 @@ #include <string.h> #include <stdlib.h> #include <unistd.h> +#include <sched.h> #include <limits.h> struct ct_general_state st; @@ -296,6 +297,23 @@ int main(int argc, char *argv[]) close(ret); /* + * Setting process priority and scheduler + */ + nice(CONFIG(nice)); + + if (CONFIG(sched).type != SCHED_OTHER) { + struct sched_param schedparam = { + .sched_priority = CONFIG(sched).prio, + }; + + ret = sched_setscheduler(0, CONFIG(sched).type, &schedparam); + if (ret == -1) { + perror("sched"); + exit(EXIT_FAILURE); + } + } + + /* * initialization process */ @@ -309,7 +327,6 @@ int main(int argc, char *argv[]) chdir("/"); close(STDIN_FILENO); - nice(CONFIG(nice)); /* Daemonize conntrackd */ if (type == DAEMON) { |