Skip to content

Commit d0c34fe

Browse files
DaanDeMeyerbluca
authored andcommitted
journal: Stop trying to open runtime journal once flushed
Once we've flushed the runtime journal to /var, stop trying to open it since that will just fail with ENOENT all the time. (cherry picked from commit 418a498) (cherry picked from commit 0146940) (cherry picked from commit ce0e97e)
1 parent d7bc48a commit d0c34fe

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/journal/journald-server.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,17 @@ static int system_journal_open(Server *s, bool flush_requested, bool relinquish_
372372

373373
fn = strjoina(s->runtime_storage.path, "/system.journal");
374374

375-
if (s->system_journal && !relinquish_requested) {
375+
if (!s->system_journal || relinquish_requested) {
376+
/* OK, we really need the runtime journal, so create it if necessary. */
377+
378+
(void) mkdir_parents(s->runtime_storage.path, 0755);
379+
(void) mkdir(s->runtime_storage.path, 0750);
380+
381+
r = open_journal(s, true, fn, O_RDWR|O_CREAT, false, &s->runtime_storage.metrics, &s->runtime_journal);
382+
if (r < 0)
383+
return log_error_errno(r, "Failed to open runtime journal: %m");
376384

385+
} else if (!flushed_flag_is_set(s)) {
377386
/* Try to open the runtime journal, but only
378387
* if it already exists, so that we can flush
379388
* it into the system journal */
@@ -385,17 +394,6 @@ static int system_journal_open(Server *s, bool flush_requested, bool relinquish_
385394

386395
r = 0;
387396
}
388-
389-
} else {
390-
391-
/* OK, we really need the runtime journal, so create it if necessary. */
392-
393-
(void) mkdir_parents(s->runtime_storage.path, 0755);
394-
(void) mkdir(s->runtime_storage.path, 0750);
395-
396-
r = open_journal(s, true, fn, O_RDWR|O_CREAT, false, &s->runtime_storage.metrics, &s->runtime_journal);
397-
if (r < 0)
398-
return log_error_errno(r, "Failed to open runtime journal: %m");
399397
}
400398

401399
if (s->runtime_journal) {

0 commit comments

Comments
 (0)