liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 26e1608fa7da7617751ea0407fa11f547245ed92
parent ad9bba4f934d2ff51c06d2dc2bc96c74c99201d7
Author: Daniel Barlow <dan@telent.net>
Date:   Sun, 26 Oct 2025 20:41:19 +0000

align log shipping start/stop messages between producer and consumer

also there's no need to make it configurable, so get rid of that

Diffstat:
Mpkgs/logtap/backfill.fnl | 6+++---
Mpkgs/logtap/logtap.c | 19+++++--------------
2 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/pkgs/logtap/backfill.fnl b/pkgs/logtap/backfill.fnl @@ -35,11 +35,11 @@ (tonumber (slurp stampfile)) 0)) - (each [l (: (io.input) :lines "L")] + (each [l (: (io.input) :lines "L")] (case l - "START SHIPPING" + "# LOG-SHIPPING-START\n" (set backfill? false) - "STOP SHIPPING" + "# LOG-SHIPPING-STOP\n" (set backfill? true) message (let [message-ts (parse-timestamp message)] diff --git a/pkgs/logtap/logtap.c b/pkgs/logtap/logtap.c @@ -40,7 +40,8 @@ struct pollfd fds[] = { { .fd = -1, .events = POLLERR }, }; -char *start_cookie, *stop_cookie; +#define START_SENTINEL "# LOG-SHIPPING-START\n" +#define STOP_SENTINEL "# LOG-SHIPPING-STOP\n" static int fifo_connected(void) { @@ -77,7 +78,7 @@ int open_shipper_fifo(char* pathname) /* write cookie to stdout so that the backfill process knows * we are now logging realtime */ - write(fds[1].fd, start_cookie, strlen(start_cookie)); + write(fds[1].fd, START_SENTINEL, sizeof START_SENTINEL); } else { fifo_retry_timeout = FIFO_RETRY_TIMEOUT_MAX; } @@ -93,18 +94,8 @@ int main(int argc, char* argv[]) int tee_bytes = 0; if (argc != 3) { - error(1, 0, "usage: " PROGRAM_NAME " /path/to/fifo cookie-text"); + error(1, 0, "usage: " PROGRAM_NAME " /path/to/fifo"); } - char* cookie = argv[2]; - start_cookie = malloc(strlen(cookie) + 9); - stop_cookie = malloc(strlen(cookie) + 8); - - strcpy(start_cookie, "\n"); - strcat(start_cookie, cookie); - strcat(start_cookie, " START\n"); - strcpy(stop_cookie, "\n"); - strcat(stop_cookie, cookie); - strcat(stop_cookie, " STOP\n"); signal(SIGPIPE, SIG_IGN); @@ -127,7 +118,7 @@ int main(int argc, char* argv[]) tee_bytes = 0; /* FIXME: nonblocking write, if stdout is not ready * we will lose the message */ - (void)write(1, stop_cookie, strlen(stop_cookie)); + (void) write(1, STOP_SENTINEL, sizeof STOP_SENTINEL); fifo_retry_timeout = FIFO_RETRY_TIMEOUT_MAX; };