diff --git a/impl/src/jsonlogger.c b/impl/src/jsonlogger.c index 3b63439..fb67122 100644 --- a/impl/src/jsonlogger.c +++ b/impl/src/jsonlogger.c @@ -1,3 +1,6 @@ +// For F_SETPIPE_SZ +#define _GNU_SOURCE + #include #include #include @@ -29,6 +32,12 @@ static bool start_message(void) } return false; } + // Increase pipe buffer to prevent/reduce EAGAIN during a JSON + // message to prevent corrupted JSON messages. 1048576 is the + // current maximum as permitted by the Linux kernel. + if (fcntl(m_fifo_fd, F_SETPIPE_SZ, 1048576) < 0) { + perror("fcntl"); + } } ssize_t ret = write(m_fifo_fd, "{", 1);