ef7b485
From 8bdb345984f8a00ff866c1b4198888a9eef03395 Mon Sep 17 00:00:00 2001
ef7b485
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
ef7b485
Date: Tue, 14 Apr 2015 20:47:20 -0500
ef7b485
Subject: [PATCH] systemctl: avoid bumping NOFILE rlimit unless needed
ef7b485
ef7b485
We actually only use the journal when showing status. Move setrlimit call
ef7b485
so it is only called for status.
ef7b485
ef7b485
https://bugzilla.redhat.com/show_bug.cgi?id=1184712
ef7b485
(cherry picked from commit 40acc203c043fd419f3c045dc6f116c3a28411d8)
ef7b485
---
ef7b485
 src/systemctl/systemctl.c | 11 ++++++-----
ef7b485
 1 file changed, 6 insertions(+), 5 deletions(-)
ef7b485
ef7b485
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
ef7b485
index 4ec0cff21d..089c25f83f 100644
ef7b485
--- a/src/systemctl/systemctl.c
ef7b485
+++ b/src/systemctl/systemctl.c
ef7b485
@@ -4449,6 +4449,12 @@ static int show(sd_bus *bus, char **args) {
ef7b485
         if (show_properties)
ef7b485
                 pager_open_if_enabled();
ef7b485
 
ef7b485
+        if (show_status)
ef7b485
+                /* Increase max number of open files to 16K if we can, we
ef7b485
+                 * might needs this when browsing journal files, which might
ef7b485
+                 * be split up into many files. */
ef7b485
+                setrlimit_closest(RLIMIT_NOFILE, &RLIMIT_MAKE_CONST(16384));
ef7b485
+
ef7b485
         /* If no argument is specified inspect the manager itself */
ef7b485
 
ef7b485
         if (show_properties && strv_length(args) <= 1)
ef7b485
@@ -7207,11 +7213,6 @@ found:
ef7b485
                 }
ef7b485
         }
ef7b485
 
ef7b485
-        /* Increase max number of open files to 16K if we can, we
ef7b485
-         * might needs this when browsing journal files, which might
ef7b485
-         * be split up into many files. */
ef7b485
-        setrlimit_closest(RLIMIT_NOFILE, &RLIMIT_MAKE_CONST(16384));
ef7b485
-
ef7b485
         return verb->dispatch(bus, argv + optind);
ef7b485
 }
ef7b485