summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-10-01 17:44:46 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-16 16:33:55 +0200
commit1abaf4887dde91bd19b36a80475a8eb03f363590 (patch)
treeb079972de26115cb375cda6c017851f9cf6c321a
parent99ab6fdf8c68bbe05a127b59ae03d2156d6ea856 (diff)
downloadsystemd-1abaf4887dde91bd19b36a80475a8eb03f363590.tar.gz
systemd-1abaf4887dde91bd19b36a80475a8eb03f363590.tar.bz2
systemd-1abaf4887dde91bd19b36a80475a8eb03f363590.zip
tree-wide: uniformly bump RLIMIT_NOFILE in all our tools that access the journal
This makes use of rlimit_nofile_bump() in all tools that access the journal. In some cases this replaces older code to achieve this, and others we add it in where it was missing.
-rw-r--r--src/coredump/coredumpctl.c5
-rw-r--r--src/journal-remote/journal-remote-main.c4
-rw-r--r--src/journal-remote/journal-upload.c4
-rw-r--r--src/journal/journalctl.c10
-rw-r--r--src/login/loginctl.c5
-rw-r--r--src/machine/machinectl.c6
-rw-r--r--src/systemctl/systemctl.c10
7 files changed, 33 insertions, 11 deletions
diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c
index 78e279db8b..8c08c64884 100644
--- a/src/coredump/coredumpctl.c
+++ b/src/coredump/coredumpctl.c
@@ -15,6 +15,7 @@
#include "bus-error.h"
#include "bus-util.h"
#include "compress.h"
+#include "def.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
@@ -26,6 +27,7 @@
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
+#include "rlimit-util.h"
#include "sigbus.h"
#include "signal-util.h"
#include "string-util.h"
@@ -1067,6 +1069,9 @@ int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
+ /* The journal merging logic potentially needs a lot of fds. */
+ (void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
+
r = parse_argv(argc, argv);
if (r <= 0)
goto end;
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
index 6d9b44e515..b52e9329ef 100644
--- a/src/journal-remote/journal-remote-main.c
+++ b/src/journal-remote/journal-remote-main.c
@@ -12,6 +12,7 @@
#include "journal-remote-write.h"
#include "journal-remote.h"
#include "process-util.h"
+#include "rlimit-util.h"
#include "signal-util.h"
#include "socket-util.h"
#include "stat-util.h"
@@ -1096,6 +1097,9 @@ int main(int argc, char **argv) {
log_show_color(true);
log_parse_environment();
+ /* The journal merging logic potentially needs a lot of fds. */
+ (void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
+
r = parse_config();
if (r < 0)
return EXIT_FAILURE;
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index 621fd620ee..88fc51ec26 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -20,6 +20,7 @@
#include "mkdir.h"
#include "parse-util.h"
#include "process-util.h"
+#include "rlimit-util.h"
#include "sigbus.h"
#include "signal-util.h"
#include "string-util.h"
@@ -780,6 +781,9 @@ int main(int argc, char **argv) {
log_show_color(true);
log_parse_environment();
+ /* The journal merging logic potentially needs a lot of fds. */
+ (void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
+
r = parse_config();
if (r < 0)
goto finish;
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 4d186014ed..9bd2d9a150 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -31,6 +31,7 @@
#include "bus-util.h"
#include "catalog.h"
#include "chattr-util.h"
+#include "def.h"
#include "device-private.h"
#include "fd-util.h"
#include "fileio.h"
@@ -2049,6 +2050,10 @@ int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
+ /* Increase max number of open files if we can, we might needs this when browsing journal files, which might be
+ * split up into many files. */
+ (void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
+
r = parse_argv(argc, argv);
if (r <= 0)
goto finish;
@@ -2056,11 +2061,6 @@ int main(int argc, char *argv[]) {
signal(SIGWINCH, columns_lines_cache_reset);
sigbus_install();
- /* Increase max number of open files to 16K if we can, we
- * might needs this when browsing journal files, which might
- * be split up into many files. */
- setrlimit_closest(RLIMIT_NOFILE, &RLIMIT_MAKE_CONST(16384));
-
switch (arg_action) {
case ACTION_NEW_ID128:
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index c9c3166f0c..39c24f8c3a 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -21,6 +21,7 @@
#include "pager.h"
#include "parse-util.h"
#include "process-util.h"
+#include "rlimit-util.h"
#include "sigbus.h"
#include "signal-util.h"
#include "spawn-polkit-agent.h"
@@ -1522,6 +1523,10 @@ int main(int argc, char *argv[]) {
setlocale(LC_ALL, "");
log_parse_environment();
log_open();
+
+ /* The journal merging logic potentially needs a lot of fds. */
+ (void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
+
sigbus_install();
r = parse_argv(argc, argv);
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 2f21f99957..d408d80c14 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -22,6 +22,7 @@
#include "cgroup-show.h"
#include "cgroup-util.h"
#include "copy.h"
+#include "def.h"
#include "env-util.h"
#include "fd-util.h"
#include "format-table.h"
@@ -37,6 +38,7 @@
#include "path-util.h"
#include "process-util.h"
#include "ptyfwd.h"
+#include "rlimit-util.h"
#include "sigbus.h"
#include "signal-util.h"
#include "spawn-polkit-agent.h"
@@ -3030,6 +3032,10 @@ int main(int argc, char*argv[]) {
setlocale(LC_ALL, "");
log_parse_environment();
log_open();
+
+ /* The journal merging logic potentially needs a lot of fds. */
+ (void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
+
sigbus_install();
r = parse_argv(argc, argv);
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 90adeb93a8..5e3040f221 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -5264,12 +5264,6 @@ static int show(int argc, char *argv[], void *userdata) {
(void) pager_open(arg_no_pager, false);
- if (show_mode == SYSTEMCTL_SHOW_STATUS)
- /* Increase max number of open files to 16K if we can, we
- * might needs this when browsing journal files, which might
- * be split up into many files. */
- setrlimit_closest(RLIMIT_NOFILE, &RLIMIT_MAKE_CONST(16384));
-
/* If no argument is specified inspect the manager itself */
if (show_mode == SYSTEMCTL_SHOW_PROPERTIES && argc <= 1)
return show_one(bus, "/org/freedesktop/systemd1", NULL, show_mode, &new_line, &ellipsized);
@@ -8661,6 +8655,10 @@ int main(int argc, char*argv[]) {
setlocale(LC_ALL, "");
log_parse_environment();
log_open();
+
+ /* The journal merging logic potentially needs a lot of fds. */
+ (void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
+
sigbus_install();
/* Explicitly not on_tty() to avoid setting cached value.