From 0dec512865d61d228fffea4aafbc4301a77212e3 Mon Sep 17 00:00:00 2001 From: Hannes Gredler Date: Tue, 19 Dec 2023 07:54:47 +0000 Subject: [PATCH] leave more room at end of buffer for cornercases --- code/lspgen/src/lspgen_ctrl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/code/lspgen/src/lspgen_ctrl.c b/code/lspgen/src/lspgen_ctrl.c index e6cd788e..7b9a89f1 100644 --- a/code/lspgen/src/lspgen_ctrl.c +++ b/code/lspgen/src/lspgen_ctrl.c @@ -295,11 +295,9 @@ lspgen_ctrl_write_cb(timer_s *timer) buffer_left = ctx->ctrl_io_buf.size - ctx->ctrl_io_buf.idx; /* - * Hexdumping doubles the data, - * plus 4 bytes for two quotation marks, comma and whitespace, - * plus 6 bytes for the json footer. + * Close the JSON message and socket once 99% of the buffer have been consumed. */ - if (buffer_left < ((packet->buf[0].idx * 2) + 4 + 6)) { + if (buffer_left < (CTRL_SOCKET_BUFSIZE/100)) { /* no space, close the JSON datagram and continue later */ LOG_NOARG(NORMAL, "End of buffer\n");