chiark / gitweb /
logind: remove unused session->closing field
[elogind.git] / src / journal / journald-server.c
index 518e9ecc4ef7bf514685d7bcd9d2c57afa4b9e7c..01e75b6629621dff8d3d3b3a6d4b89bbf553daff 100644 (file)
 #include <sys/timerfd.h>
 
 #include <libudev.h>
-#include <systemd/sd-journal.h>
-#include <systemd/sd-messages.h>
-#include <systemd/sd-daemon.h>
 
+#include "sd-journal.h"
+#include "sd-messages.h"
+#include "sd-daemon.h"
 #include "fileio.h"
 #include "mkdir.h"
 #include "hashmap.h"
 #include "socket-util.h"
 #include "cgroup-util.h"
 #include "list.h"
-#include "virt.h"
 #include "missing.h"
 #include "conf-parser.h"
+#include "selinux-util.h"
 #include "journal-internal.h"
 #include "journal-vacuum.h"
 #include "journal-authenticate.h"
-#include "journald-server.h"
 #include "journald-rate-limit.h"
 #include "journald-kmsg.h"
 #include "journald-syslog.h"
 #include "journald-stream.h"
 #include "journald-console.h"
 #include "journald-native.h"
-#include "selinux-util.h"
+#include "journald-server.h"
 
 #ifdef HAVE_ACL
 #include <sys/acl.h>
@@ -971,9 +970,12 @@ static int system_journal_open(Server *s) {
 }
 
 int server_flush_to_var(Server *s) {
-        int r;
         sd_id128_t machine;
         sd_journal *j = NULL;
+        char ts[FORMAT_TIMESPAN_MAX];
+        usec_t start;
+        unsigned n = 0;
+        int r;
 
         assert(s);
 
@@ -991,6 +993,8 @@ int server_flush_to_var(Server *s) {
 
         log_debug("Flushing to /var...");
 
+        start = now(CLOCK_MONOTONIC);
+
         r = sd_id128_get_machine(&machine);
         if (r < 0)
                 return r;
@@ -1010,6 +1014,8 @@ int server_flush_to_var(Server *s) {
                 f = j->current_file;
                 assert(f && f->current_offset > 0);
 
+                n++;
+
                 r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o);
                 if (r < 0) {
                         log_error("Can't read entry: %s", strerror(-r));
@@ -1053,6 +1059,8 @@ finish:
 
         sd_journal_close(j);
 
+        server_driver_message(s, SD_ID128_NULL, "Time spent on flushing to /var is %s for %u entries.", format_timespan(ts, sizeof(ts), now(CLOCK_MONOTONIC) - start, 0), n);
+
         return r;
 }
 
@@ -1313,17 +1321,14 @@ static int open_signalfd(Server *s) {
 static int server_parse_proc_cmdline(Server *s) {
         _cleanup_free_ char *line = NULL;
         char *w, *state;
-        int r;
         size_t l;
+        int r;
 
-        if (detect_container(NULL) > 0)
-                return 0;
-
-        r = read_one_line_file("/proc/cmdline", &line);
-        if (r < 0) {
+        r = proc_cmdline(&line);
+        if (r < 0)
                 log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
+        if (r <= 0)
                 return 0;
-        }
 
         FOREACH_WORD_QUOTED(w, l, line, state) {
                 _cleanup_free_ char *word;