|
1 | 1 | #define _GNU_SOURCE |
2 | 2 | #include "ctr_logging.h" |
| 3 | +#include "globals.h" |
3 | 4 | #include "cli.h" |
4 | 5 | #include "config.h" |
5 | 6 | #include <ctype.h> |
@@ -355,10 +356,18 @@ static int parse_priority_prefix(const char *buf, size_t buflen, int *priority, |
355 | 356 | */ |
356 | 357 | static int write_journald(int pipe, char *buf, size_t buflen) |
357 | 358 | { |
358 | | - static char stdout_partial_buf[STDIO_BUF_SIZE]; |
| 359 | + static char *stdout_partial_buf = NULL; |
359 | 360 | static size_t stdout_partial_buf_len = 0; |
360 | | - static char stderr_partial_buf[STDIO_BUF_SIZE]; |
| 361 | + static char *stderr_partial_buf = NULL; |
361 | 362 | static size_t stderr_partial_buf_len = 0; |
| 363 | + size_t buf_size = (pipe == STDOUT_PIPE ? mainfd_stdout_size : mainfd_stderr_size); |
| 364 | + |
| 365 | + if (stdout_partial_buf == NULL) { |
| 366 | + stdout_partial_buf = g_malloc(mainfd_stdout_size); |
| 367 | + } |
| 368 | + if (stderr_partial_buf == NULL) { |
| 369 | + stderr_partial_buf = g_malloc(mainfd_stderr_size); |
| 370 | + } |
362 | 371 |
|
363 | 372 | char *partial_buf; |
364 | 373 | size_t *partial_buf_len; |
@@ -388,7 +397,7 @@ static int write_journald(int pipe, char *buf, size_t buflen) |
388 | 397 | /* If this is a partial line, and we have capacity to buffer it, buffer it and return. |
389 | 398 | * The capacity of the partial_buf is one less than its size so that we can always add |
390 | 399 | * a null terminating char later */ |
391 | | - if (buflen && partial && ((unsigned long)line_len < (STDIO_BUF_SIZE - *partial_buf_len))) { |
| 400 | + if (buflen && partial && ((unsigned long)line_len < (buf_size - *partial_buf_len))) { |
392 | 401 | memcpy(partial_buf + *partial_buf_len, buf, line_len); |
393 | 402 | *partial_buf_len += line_len; |
394 | 403 | return 0; |
|
0 commit comments