multipathd: Read environment variables from systemd
authorHannes Reinecke <hare@suse.de>
Tue, 26 Nov 2013 11:41:29 +0000 (12:41 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Sat, 30 Nov 2013 14:55:49 +0000 (15:55 +0100)
When systemd adjusts 'OOMScoreAdjust' and 'LimitNOFILE'
we should take those settings and not try to adjust them
again on our side.

Signed-off-by: Hannes Reinecke <hare@suse.de>
multipathd/main.c

index d8d1204..9b4e7c0 100644 (file)
@@ -1552,7 +1552,13 @@ set_oom_adj (void)
 #endif
        FILE *fp;
        struct stat st;
+       char *envp;
 
+       envp = getenv("OOMScoreAdjust");
+       if (envp) {
+               condlog(3, "Using systemd provided OOMScoreAdjust");
+               return;
+       }
        do {
                if (stat(file, &st) == 0){
                        fp = fopen(file, "w");
@@ -1628,7 +1634,11 @@ child (void * param)
 
        setlogmask(LOG_UPTO(conf->verbosity + 3));
 
-       if (conf->max_fds) {
+       envp = getenv("LimitNOFILE");
+
+       if (envp) {
+               condlog(2,"Using systemd provided open fds limit of %s", envp);
+       } else if (conf->max_fds) {
                struct rlimit fd_limit;
 
                if (getrlimit(RLIMIT_NOFILE, &fd_limit) < 0) {