mirror of
https://github.com/optim-enterprises-bv/nDPId.git
synced 2025-11-01 18:57:48 +00:00
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:
11
nDPId.c
11
nDPId.c
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user