Skip to content

Commit

Permalink
journald: Increase stdout buffer size sooner, when almost full
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit 034e971)

Related: #2029426
  • Loading branch information
benjarobin authored and systemd-rhel-bot committed Feb 27, 2023
1 parent b18e19f commit a0b5239
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/journal/journald-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,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;
Expand Down

0 comments on commit a0b5239

Please sign in to comment.