Re-configure max open files if setting soft limit has failed
authorJeroen van der Heijden <jeroen@transceptor.technology>
Wed, 26 Feb 2020 19:55:09 +0000 (20:55 +0100)
committerJeroen van der Heijden <jeroen@transceptor.technology>
Wed, 26 Feb 2020 19:55:09 +0000 (20:55 +0100)
src/siri/cfg/cfg.c

index 93fe561e3d5723ed98da2a78a8a9bf529e091c30..9a6c8b47a5df3ab0a7c62c652d6b344b26016944 100644 (file)
@@ -577,6 +577,7 @@ static void SIRI_CFG_read_max_open_files(cfgparser_t * cfgparser)
 
     if (min_limit > (uint64_t) rlim.rlim_cur)
     {
+        rlim_t prev = rlim.rlim_cur;
         log_info(
                 "Increasing soft-limit from %d to %d since we want "
                 "to use only %d%% from the soft-limit for shard files",
@@ -586,7 +587,7 @@ static void SIRI_CFG_read_max_open_files(cfgparser_t * cfgparser)
         rlim.rlim_cur = min_limit;
         if (setrlimit(RLIMIT_NOFILE, &rlim))
         {
-            siri_cfg.max_open_files = (uint16_t) (rlim.rlim_cur / 2);
+            siri_cfg.max_open_files = (uint16_t) (prev / 2);
             log_warning("Could not set the soft-limit to %d, "
                     "changing max open files to: %u",
                     min_limit, siri_cfg.max_open_files);