[PATCH] lib/telemetry:fix telemetry conns leak in case of socket write fail

Power, Ciara ciara.power at intel.com
Fri Jan 19 16:42:39 CET 2024



> -----Original Message-----
> From: sunshaowei01 <1819846787 at qq.com>
> Sent: Friday, January 19, 2024 11:40 AM
> To: dev at dpdk.org
> Cc: Power, Ciara <ciara.power at intel.com>
> Subject: [PATCH] lib/telemetry:fix telemetry conns leak in case of socket write
> fail
> 
> 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
> 
> Signed-off-by: sunshaowei01 <1819846787 at qq.com>
> ---
>  lib/telemetry/telemetry.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index
> 31e2391867..0b00c04090 100644
> --- a/lib/telemetry/telemetry.c
> +++ b/lib/telemetry/telemetry.c
> @@ -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;
> --
> 2.37.1 (Apple Git-137.1)

Thanks for fixing this.

Acked-by: Ciara Power <ciara.power at intel.com>



More information about the dev mailing list