]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journalctl: show duplicate entries if they are from the same file (#14898)
authorGeorg Müller <georgmueller@gmx.net>
Thu, 20 Feb 2020 18:19:41 +0000 (19:19 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 11 Mar 2020 08:12:00 +0000 (09:12 +0100)
When having a service which intentionally outputs multiple equal lines,
all these messages might be inserted with the same timestamp.

journalctl has a mechanism to avoid duplicate lines, which might be in
different journal files.

This patch allows duplicate lines, if they are from the same file.

src/journal/sd-journal.c

index 3fa98dfda237c84ab14fe1291cd5164e24bb1095..17998090f431a744de45ef3203ad7f581bb454aa 100644 (file)
@@ -435,11 +435,12 @@ _public_ void sd_journal_flush_matches(sd_journal *j) {
         detach_location(j);
 }
 
-_pure_ static int compare_with_location(JournalFile *f, Location *l) {
+_pure_ static int compare_with_location(const JournalFile *f, const Location *l, const JournalFile *current_file) {
         int r;
 
         assert(f);
         assert(l);
+        assert(current_file);
         assert(f->location_type == LOCATION_SEEK);
         assert(IN_SET(l->type, LOCATION_DISCRETE, LOCATION_SEEK));
 
@@ -448,7 +449,8 @@ _pure_ static int compare_with_location(JournalFile *f, Location *l) {
             l->realtime_set &&
             f->current_realtime == l->realtime &&
             l->xor_hash_set &&
-            f->current_xor_hash == l->xor_hash)
+            f->current_xor_hash == l->xor_hash &&
+            f != current_file)
                 return 0;
 
         if (l->seqnum_set &&
@@ -787,7 +789,7 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc
                 if (j->current_location.type == LOCATION_DISCRETE) {
                         int k;
 
-                        k = compare_with_location(f, &j->current_location);
+                        k = compare_with_location(f, &j->current_location, j->current_file);
 
                         found = direction == DIRECTION_DOWN ? k > 0 : k < 0;
                 } else