From 717d66b0e7a05eb0d22c85fda7a4448885e7f1ec Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Sun, 18 Feb 2024 23:16:31 +0100 Subject: Fixed missing statistics updating for unknown mapping keys in collectd/influxd. Signed-off-by: Toni Uhlig --- examples/c-collectd/c-collectd.c | 5 ++++- examples/c-influxd/c-influxd.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/c-collectd/c-collectd.c b/examples/c-collectd/c-collectd.c index e17267ee3..9f230495a 100644 --- a/examples/c-collectd/c-collectd.c +++ b/examples/c-collectd/c-collectd.c @@ -1074,6 +1074,8 @@ static ssize_t collectd_map_index(char const * const json_key, struct global_map const * const map, size_t map_length) { + ssize_t unknown_key = -1; + if (json_key == NULL || key_length == 0) { return -1; @@ -1083,6 +1085,7 @@ static ssize_t collectd_map_index(char const * const json_key, { if (map[i].json_key == NULL) { + unknown_key = i; continue; } @@ -1092,7 +1095,7 @@ static ssize_t collectd_map_index(char const * const json_key, } } - return -1; + return unknown_key; } static int collectd_map_flow_u8(struct nDPIsrvd_socket * const sock, diff --git a/examples/c-influxd/c-influxd.c b/examples/c-influxd/c-influxd.c index ed6f2e99e..c58c36ae3 100644 --- a/examples/c-influxd/c-influxd.c +++ b/examples/c-influxd/c-influxd.c @@ -946,6 +946,8 @@ static ssize_t influxd_map_index(char const * const json_key, struct global_map const * const map, size_t map_length) { + ssize_t unknown_key = -1; + if (json_key == NULL || key_length == 0) { return -1; @@ -955,6 +957,7 @@ static ssize_t influxd_map_index(char const * const json_key, { if (map[i].json_key == NULL) { + unknown_key = i; continue; } @@ -964,7 +967,7 @@ static ssize_t influxd_map_index(char const * const json_key, } } - return -1; + return unknown_key; } static int influxd_map_flow_u8(struct nDPIsrvd_socket * const sock, -- cgit v1.2.3