diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-01-29 02:10:15 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-01-29 02:11:55 +0100 |
commit | 9e8abdf0d9f0fa11fbceb02dfd36252bd32a534e (patch) | |
tree | 2a581ca0fa0eab050b712c3d39839d19331cc972 /src/journal/sd-journal.c | |
parent | 6c2b9c8da1eb1bac7e8f170b913f63dbd13a16d7 (diff) |
Revert "journal: do not check for number of files"
This reverts commit b914ea8d379b446c4c9fac4ba181771676ef38cd.
We really need to put a limit on all our resources, everywhere, and in
particular if we operate on external data.
Hence, let's reintroduce the limit, but bump it substantially, so that
it is guaranteed to be higher than any realistic RLIMIT_NOFILE setting.
Diffstat (limited to 'src/journal/sd-journal.c')
-rw-r--r-- | src/journal/sd-journal.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index 0268675abb..9bc426faf8 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -43,6 +43,8 @@ #include "replace-var.h" #include "fileio.h" +#define JOURNAL_FILES_MAX 7168 + #define JOURNAL_FILES_RECHECK_USEC (2 * USEC_PER_SEC) #define REPLACE_VAR_MAX 256 @@ -1196,6 +1198,11 @@ static int add_any_file(sd_journal *j, const char *path) { if (ordered_hashmap_get(j->files, path)) return 0; + if (ordered_hashmap_size(j->files) >= JOURNAL_FILES_MAX) { + log_warning("Too many open journal files, not adding %s.", path); + return set_put_error(j, -ETOOMANYREFS); + } + r = journal_file_open(path, O_RDONLY, 0, false, false, NULL, j->mmap, NULL, &f); if (r < 0) return r; |