summaryrefslogtreecommitdiffstats
path: root/src/run.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/run.c')
-rw-r--r--src/run.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/run.c b/src/run.c
index 1fe6cba..f11a532 100644
--- a/src/run.c
+++ b/src/run.c
@@ -32,6 +32,7 @@
#include "internal.h"
#include "systemd.h"
+#include <sched.h>
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
@@ -234,11 +235,35 @@ int evaluate(void)
return 0;
}
+
+static void set_scheduler(void)
+{
+ struct sched_param schedparam;
+ int sched_type;
+
+ if (CONFIG(sched).type == SCHED_OTHER) {
+ /* default */
+ schedparam.sched_priority = sched_get_priority_max(SCHED_RR);
+ sched_type = SCHED_RR;
+ } else {
+ schedparam.sched_priority = CONFIG(sched).prio;
+ sched_type = CONFIG(sched).type;
+ }
+
+ if (sched_setscheduler(0, sched_type, &schedparam) < 0)
+ dlog(LOG_WARNING, "scheduler configuration failed: %s. "
+ "Likely a bug in conntrackd, please report it. "
+ "Continuing with system default scheduler.",
+ strerror(errno));
+}
+
int
init(void)
{
do_gettimeofday();
+ set_scheduler();
+
STATE(fds) = create_fds();
if (STATE(fds) == NULL) {
dlog(LOG_ERR, "can't create file descriptor pool");