]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald: Increase stdout buffer size sooner, when almost full
authorBenjamin Robin <dev@benjarobin.fr>
Sun, 3 May 2020 16:37:21 +0000 (18:37 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 13 May 2020 19:31:58 +0000 (21:31 +0200)
If the previous received buffer length is almost equal to the allocated
buffer size, before this change the next read can only receive a couple
of bytes (in the worst case only 1 byte), which is not efficient.

src/journal/journald-stream.c

index 4dadbd62bec3201d9be4781470e893bf2c753393..6c10bfc259312712614f25da1c72fd8ebc2c8d14 100644 (file)
@@ -511,8 +511,8 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents,
                 goto terminate;
         }
 
-        /* If the buffer is full already (discounting the extra NUL we need), add room for another 1K */
-        if (s->length + 1 >= s->allocated) {
+        /* If the buffer is almost full, add room for another 1K */
+        if (s->length + 512 >= s->allocated) {
                 if (!GREEDY_REALLOC(s->buffer, s->allocated, s->length + 1 + 1024)) {
                         log_oom();
                         goto terminate;