]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
missing: if RLIMIT_RTTIME is not defined by the libc, then we need a new define for...
authorLennart Poettering <lennart@poettering.net>
Wed, 5 Mar 2014 01:29:58 +0000 (02:29 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 5 Mar 2014 01:31:09 +0000 (02:31 +0100)
src/core/execute.c
src/core/execute.h
src/core/main.c
src/core/manager.c
src/core/manager.h
src/core/unit.c
src/shared/missing.h
src/shared/util.c

index fec4b3b13a0cfe2f714ccd818bc13d58ea61fcc1..ca807dc8cb2fa86ff9b2afbba8dc9ecc70d88fe8 100644 (file)
@@ -1676,7 +1676,7 @@ int exec_spawn(ExecCommand *command,
 
                 if (apply_permissions) {
 
-                        for (i = 0; i < RLIMIT_NLIMITS; i++) {
+                        for (i = 0; i < _RLIMIT_MAX; i++) {
                                 if (!context->rlimit[i])
                                         continue;
 
index 2c5d8bbf76ffb15a5f901143f897ef7d1d0ee367..a3336573280ba4cbdb558d5dc314f9b31103e292 100644 (file)
@@ -38,6 +38,7 @@ typedef struct ExecRuntime ExecRuntime;
 #include "util.h"
 #include "set.h"
 #include "fdset.h"
+#include "missing.h"
 
 typedef enum ExecInput {
         EXEC_INPUT_NULL,
@@ -93,7 +94,7 @@ struct ExecContext {
         char **environment;
         char **environment_files;
 
-        struct rlimit *rlimit[RLIMIT_NLIMITS];
+        struct rlimit *rlimit[_RLIMIT_MAX];
         char *working_directory, *root_directory;
 
         mode_t umask;
index 4ca847c78124daf63f6f28263b31681ee18bf7b7..25ddafee4726c6ee7492c883952d3dc151e88e95 100644 (file)
@@ -105,7 +105,7 @@ static unsigned arg_default_start_limit_burst = DEFAULT_START_LIMIT_BURST;
 static usec_t arg_runtime_watchdog = 0;
 static usec_t arg_shutdown_watchdog = 10 * USEC_PER_MINUTE;
 static char **arg_default_environment = NULL;
-static struct rlimit *arg_default_rlimit[RLIMIT_NLIMITS] = {};
+static struct rlimit *arg_default_rlimit[_RLIMIT_MAX] = {};
 static uint64_t arg_capability_bounding_set_drop = 0;
 static nsec_t arg_timer_slack_nsec = (nsec_t) -1;
 static Set* arg_syscall_archs = NULL;
index 822c7ccfee43d3231db758374f6528fbed29ee22..e4d03681ab089a06a0d278c90ae8c7aef5927ac4 100644 (file)
@@ -810,7 +810,7 @@ void manager_free(Manager *m) {
         free(m->switch_root);
         free(m->switch_root_init);
 
-        for (i = 0; i < RLIMIT_NLIMITS; i++)
+        for (i = 0; i < _RLIMIT_MAX; i++)
                 free(m->rlimit[i]);
 
         assert(hashmap_isempty(m->units_requiring_mounts_for));
@@ -2728,7 +2728,7 @@ int manager_set_default_rlimits(Manager *m, struct rlimit **default_rlimit) {
 
         assert(m);
 
-        for (i = 0; i < RLIMIT_NLIMITS; i++) {
+        for (i = 0; i < _RLIMIT_MAX; i++) {
                 if (!default_rlimit[i])
                         continue;
 
index 92985caefb524b70194508bfda0e3f38b2d2ab7c..e014abd04f6e6544ee08bd8a365668f1243f6ab1 100644 (file)
@@ -228,7 +228,7 @@ struct Manager {
         bool default_memory_accounting;
         bool default_blockio_accounting;
 
-        struct rlimit *rlimit[RLIMIT_NLIMITS];
+        struct rlimit *rlimit[_RLIMIT_MAX];
 
         /* non-zero if we are reloading or reexecuting, */
         int n_reloading;
index d0e915909af20fb9c7b4cca9140e3ca8210015c6..2437ee3f66afd113763db4eab10167a8cf578d8f 100644 (file)
@@ -2803,7 +2803,7 @@ int unit_exec_context_patch_defaults(Unit *u, ExecContext *c) {
          * _after_ the rest of the settings have been initialized */
 
         /* This only copies in the ones that need memory */
-        for (i = 0; i < RLIMIT_NLIMITS; i++)
+        for (i = 0; i < _RLIMIT_MAX; i++)
                 if (u->manager->rlimit[i] && !c->rlimit[i]) {
                         c->rlimit[i] = newdup(struct rlimit, u->manager->rlimit[i], 1);
                         if (!c->rlimit[i])
index 06c69dac8efff4562b16f2079cbd01646c19ded9..4e63fb9ac450a627adac1eb8e2788770036c2b80 100644 (file)
@@ -47,6 +47,9 @@
 #define RLIMIT_RTTIME 15
 #endif
 
+/* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */
+#define _RLIMIT_MAX (RLIMIT_RTTIME+1 > RLIMIT_NLIMITS ? RLIMIT_RTTIME+1 : RLIMIT_NLIMITS)
+
 #ifndef F_LINUX_SPECIFIC_BASE
 #define F_LINUX_SPECIFIC_BASE 1024
 #endif
index 10daff3036071a7944a826d1a080b1d4d2193caf..8c7cfbd6df7f548dd21e12b72c3471e82598ea3b 100644 (file)
@@ -83,6 +83,7 @@
 #include "gunicode.h"
 #include "virt.h"
 #include "def.h"
+#include "missing.h"
 
 int saved_argc = 0;
 char **saved_argv = NULL;
@@ -4713,7 +4714,7 @@ static const char* const sched_policy_table[] = {
 
 DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(sched_policy, int, INT_MAX);
 
-static const char* const rlimit_table[] = {
+static const char* const rlimit_table[_RLIMIT_MAX] = {
         [RLIMIT_CPU] = "LimitCPU",
         [RLIMIT_FSIZE] = "LimitFSIZE",
         [RLIMIT_DATA] = "LimitDATA",