]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-upload : Ignore journal event when already in uploading state. 2071/head
authorKlearchos Chaloulos <klearchos.chaloulos@nokia.com>
Wed, 9 Dec 2015 16:34:36 +0000 (18:34 +0200)
committerKlearchos Chaloulos <klearchos.chaloulos@nokia.com>
Wed, 9 Dec 2015 16:34:36 +0000 (18:34 +0200)
When the log rate is high, it is possible that the callback dispatch_journal_input() will be called twice, while the program is in uploading state. There is a guard for this in dispatch_journal_input(). However it is not enough, as it is possible that the uploading state is not set when the code is in dispatch_journal_input().
The result of the above is that a log would be skipped, as sd_journal_next_skip() would be called twice.
Adding a new check in process_journal_input(), just before the code to sd_journal_next_skip(),  makes sure that the code ignores a duplicate callback, when the first callback is in uploading state.
Also, removed the warning log from dispatch_journal_input(), as this occurence is normal.

src/journal-remote/journal-upload-journal.c

index a6d7c3b7e8c8d9fffbf49c4c1935f31e18b6d35d..f9d2385215a98bd4d19157252f8d1a29d76cfaff 100644 (file)
@@ -312,6 +312,9 @@ void close_journal_input(Uploader *u) {
 static int process_journal_input(Uploader *u, int skip) {
         int r;
 
+        if (u->uploading)
+                return 0;
+
         r = sd_journal_next_skip(u->journal, skip);
         if (r < 0)
                 return log_error_errno(r, "Failed to skip to next entry: %m");
@@ -349,10 +352,8 @@ static int dispatch_journal_input(sd_event_source *event,
 
         assert(u);
 
-        if (u->uploading) {
-                log_warning("dispatch_journal_input called when uploading, ignoring.");
+        if (u->uploading)
                 return 0;
-        }
 
         log_debug("Detected journal input, checking for new data.");
         return check_journal_input(u);