dryang / rpms / systemd

Forked from rpms/systemd a year ago
Clone
6f381c
From a0b52398692f3e4bda18520db9e2397f7b2c80dd Mon Sep 17 00:00:00 2001
6f381c
From: Benjamin Robin <dev@benjarobin.fr>
6f381c
Date: Sun, 3 May 2020 18:37:21 +0200
6f381c
Subject: [PATCH] journald: Increase stdout buffer size sooner, when almost
6f381c
 full
6f381c
6f381c
If the previous received buffer length is almost equal to the allocated
6f381c
buffer size, before this change the next read can only receive a couple
6f381c
of bytes (in the worst case only 1 byte), which is not efficient.
6f381c
6f381c
(cherry picked from commit 034e9719ac1ba88a36b05da38c7aa98761d42c77)
6f381c
6f381c
Related: #2029426
6f381c
---
6f381c
 src/journal/journald-stream.c | 4 ++--
6f381c
 1 file changed, 2 insertions(+), 2 deletions(-)
6f381c
6f381c
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
6f381c
index 302a82d3d7..c8de984335 100644
6f381c
--- a/src/journal/journald-stream.c
6f381c
+++ b/src/journal/journald-stream.c
6f381c
@@ -507,8 +507,8 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents,
6f381c
                 goto terminate;
6f381c
         }
6f381c
 
6f381c
-        /* If the buffer is full already (discounting the extra NUL we need), add room for another 1K */
6f381c
-        if (s->length + 1 >= s->allocated) {
6f381c
+        /* If the buffer is almost full, add room for another 1K */
6f381c
+        if (s->length + 512 >= s->allocated) {
6f381c
                 if (!GREEDY_REALLOC(s->buffer, s->allocated, s->length + 1 + 1024)) {
6f381c
                         log_oom();
6f381c
                         goto terminate;