]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald: close runtime journals before their parent directory removed
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 3 Dec 2023 12:41:55 +0000 (21:41 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 4 Dec 2023 06:14:25 +0000 (15:14 +0900)
No functional change, just for safety.

src/journal/journald-server.c

index f2f5220367778071bf10f6d6003c0ce05598d443..d7c8095d7954fb34081c58db95a62d533a51f16d 100644 (file)
@@ -1353,13 +1353,16 @@ finish:
         if (s->system_journal)
                 journal_file_post_change(s->system_journal);
 
+        /* First, close all runtime journals opened in the above. */
+        sd_journal_close(j);
+
+        /* Offline and close the 'main' runtime journal file. */
         s->runtime_journal = journal_file_offline_close(s->runtime_journal);
 
+        /* Remove the runtime directory if the all entries are successfully flushed to /var/. */
         if (r >= 0)
                 (void) rm_rf(s->runtime_storage.path, REMOVE_ROOT);
 
-        sd_journal_close(j);
-
         server_driver_message(s, 0, NULL,
                               LOG_MESSAGE("Time spent on flushing to %s is %s for %u entries.",
                                           s->system_storage.path,