nDPId-test: Reworked I/O handling to prevent some endless loop scenarios. Fixed a race condition in the memory wrapper as well.

* nDPId: Instead of sending too long JSON strings, log an error and some parts.

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
Toni Uhlig
2022-11-20 10:22:02 +01:00
parent 532961af33
commit 2c95b31210
3 changed files with 215 additions and 79 deletions

11
nDPId.c
View File

@@ -2221,7 +2221,7 @@ static void send_to_collector(struct nDPId_reader_thread * const reader_thread,
(int)json_str_len,
json_str);
if (s_ret < 0 || s_ret == (int)sizeof(newline_json_str))
if (s_ret < 0 || s_ret >= (int)sizeof(newline_json_str))
{
logger(1,
"[%8llu, %zu] JSON buffer prepare failed: snprintf returned %d, buffer size %zu",
@@ -2229,6 +2229,15 @@ static void send_to_collector(struct nDPId_reader_thread * const reader_thread,
reader_thread->array_index,
s_ret,
sizeof(newline_json_str));
if (s_ret >= (int)sizeof(newline_json_str))
{
logger(1,
"[%8llu, %zu] JSON string: %.*s...",
workflow->packets_captured,
reader_thread->array_index,
ndpi_min(512, NETWORK_BUFFER_MAX_SIZE),
newline_json_str);
}
return;
}