]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4093] Moved setpriority
authorFrancis Dupont <fdupont@isc.org>
Wed, 4 Mar 2026 08:16:23 +0000 (09:16 +0100)
committerFrancis Dupont <fdupont@isc.org>
Thu, 18 Jun 2026 07:30:05 +0000 (09:30 +0200)
src/bin/lfc/lfc_controller.cc
src/bin/lfc/main.cc

index 27a7e3d02750477bb5024ed6e079a887a652c716..2198e7ca83211e2111d4190036be621e36811864 100644 (file)
@@ -26,6 +26,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <cerrno>
+#include <sys/resource.h>
 
 using namespace std;
 using namespace isc::util;
@@ -102,6 +103,13 @@ LFCController::launch(int argc, char* argv[], const bool test_mode) {
         if (existing == 0) {
             pid_file.write();
         }
+
+        // Ask scheduling to not give too much resources to LFC.
+        // First parameter means to change only the process priority.
+        // Second parameter (0) means the calling process.
+        // Third parameter 4 is a bit below the default priority of 0 in
+        // a range of -20 (highest priority) and 19 or 20 (lowest priority).
+        static_cast<void>(setpriority(PRIO_PROCESS, 0, 4));
     } catch (const PIDFileError& pid_ex) {
         LOG_FATAL(lfc_logger, LFC_FAIL_PID_CREATE).arg(pid_ex.what());
         return;
index 61f4c34ef0d0f4a538bae66b535d3281111635c3..05bb8dd20aba00f55ec3663d615594fe47d42e97 100644 (file)
@@ -13,7 +13,6 @@
 #include <boost/exception/diagnostic_information.hpp>
 #include <boost/exception_ptr.hpp>
 #include <iostream>
-#include <sys/resource.h>
 
 using namespace std;
 using namespace isc::lfc;
@@ -29,13 +28,6 @@ int main(int argc, char* argv[]) {
 
     int ret = EXIT_SUCCESS;
     try {
-        // Ask scheduling to not give too much resources to LFC.
-        // First parameter means to change only the process priority.
-        // Second parameter (0) means the calling process.
-        // Third parameter 4 is a bit below the default priority of 0 in
-        // a range of -20 (highest priority) and 19 or 20 (lowest priority).
-        static_cast<void>(setpriority(PRIO_PROCESS, 0, 4));
-
         LFCController lfc_controller;
 
         // Launch the controller passing in command line arguments.