]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: recalculate line_max when stdout stream state changes
authorFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 9 Nov 2023 12:24:57 +0000 (13:24 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 9 Nov 2023 12:29:00 +0000 (13:29 +0100)
Otherwise we might still use the more restrictive limit when we get to
STDOUT_STREAM_RUNNING, causing unexpected line breaks in the journal
messages.

Follow-up to: 80e9720616
Resolves: #29916

src/journal/journald-stream.c

index 05a715e46bdc070ac0762dc270138e6d7539c8c9..81a0e68281718b569e297cbf785474f65bbb706c 100644 (file)
@@ -502,19 +502,21 @@ static int stdout_stream_scan(
                 LineBreak force_flush,
                 size_t *ret_consumed) {
 
-        size_t consumed = 0, line_max;
+        size_t consumed = 0;
         int r;
 
         assert(s);
         assert(p);
 
-        line_max = stdout_stream_line_max(s);
 
         for (;;) {
                 LineBreak line_break;
                 size_t skip, found;
                 char *end1, *end2;
-                size_t tmp_remaining = MIN(remaining, line_max);
+                size_t tmp_remaining, line_max;
+
+                line_max = stdout_stream_line_max(s);
+                tmp_remaining = MIN(remaining, line_max);
 
                 end1 = memchr(p, '\n', tmp_remaining);
                 end2 = memchr(p, 0, end1 ? (size_t) (end1 - p) : tmp_remaining);