[v2] lib/telemetry:fix telemetry conns leak in case of socket write fail
Checks
Commit Message
Telemetry can only create 10 conns by default, each of which is processed
by a thread.
When a thread fails to write using socket, the thread will end directly
without reducing the total number of conns.
This will result in the machine running for a long time, and if there are
10 failures, the telemetry will be unavailable
Fixes: 6dd571fd07c3 ("telemetry: introduce new functionality")
Signed-off-by: Shaowei Sun <1819846787@qq.com>
---
lib/telemetry/telemetry.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
@@ -378,8 +378,8 @@ client_handler(void *sock_id)
"{\"version\":\"%s\",\"pid\":%d,\"max_output_len\":%d}",
telemetry_version, getpid(), MAX_OUTPUT_LEN);
if (write(s, info_str, strlen(info_str)) < 0) {
- close(s);
- return NULL;
+ TMTY_LOG_LINE(ERR, "Socket write base info to client failed");
+ goto exit;
}
/* receive data is not null terminated */
@@ -404,6 +404,7 @@ client_handler(void *sock_id)
bytes = read(s, buffer, sizeof(buffer) - 1);
}
+exit:
close(s);
rte_atomic_fetch_sub_explicit(&v2_clients, 1, rte_memory_order_relaxed);
return NULL;