DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] lib/telemetry:fix telemetry conns leak in case of socket write fail
@ 2024-01-19 16:25 Shaowei Sun
  0 siblings, 0 replies; 6+ messages in thread
From: Shaowei Sun @ 2024-01-19 16:25 UTC (permalink / raw)
  To: dev; +Cc: ciara.power

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(-)

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)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] lib/telemetry:fix telemetry conns leak in case of socket write fail
@ 2024-01-19 16:12 sunshaowei01
  0 siblings, 0 replies; 6+ messages in thread
From: sunshaowei01 @ 2024-01-19 16:12 UTC (permalink / raw)
  To: dev; +Cc: ciara.power, Shaowei Sun

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(-)

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)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] lib/telemetry:fix telemetry conns leak in case of socket write fail
  2024-01-19 11:40 sunshaowei01
  2024-01-19 11:54 ` Bruce Richardson
  2024-01-19 15:42 ` Power, Ciara
@ 2024-01-19 15:54 ` David Marchand
  2 siblings, 0 replies; 6+ messages in thread
From: David Marchand @ 2024-01-19 15:54 UTC (permalink / raw)
  To: sunshaowei01; +Cc: dev, ciara.power, Bruce Richardson

Hello,

On Fri, Jan 19, 2024 at 12:40 PM sunshaowei01 <1819846787@qq.com> wrote:
>
> 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
>

Thanks for the patch, do you know which commit first triggered the issue?
This is needed so we add a Fixes: tag in the commitlog for backporting
the fix in stable releases.
See https://doc.dpdk.org/guides/contributing/patches.html#patch-fix-related-issues

> Signed-off-by: sunshaowei01 <1819846787@qq.com>

We need your full name in the SoB tag.
Like, for example in my case, it would be David Marchand
<david.marchand@redhat.com>.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] lib/telemetry:fix telemetry conns leak in case of socket write fail
  2024-01-19 11:40 sunshaowei01
  2024-01-19 11:54 ` Bruce Richardson
@ 2024-01-19 15:42 ` Power, Ciara
  2024-01-19 15:54 ` David Marchand
  2 siblings, 0 replies; 6+ messages in thread
From: Power, Ciara @ 2024-01-19 15:42 UTC (permalink / raw)
  To: sunshaowei01, dev



> -----Original Message-----
> From: sunshaowei01 <1819846787@qq.com>
> Sent: Friday, January 19, 2024 11:40 AM
> To: dev@dpdk.org
> Cc: Power, Ciara <ciara.power@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@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@intel.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] lib/telemetry:fix telemetry conns leak in case of socket write fail
  2024-01-19 11:40 sunshaowei01
@ 2024-01-19 11:54 ` Bruce Richardson
  2024-01-19 15:42 ` Power, Ciara
  2024-01-19 15:54 ` David Marchand
  2 siblings, 0 replies; 6+ messages in thread
From: Bruce Richardson @ 2024-01-19 11:54 UTC (permalink / raw)
  To: sunshaowei01; +Cc: dev, ciara.power

On Fri, Jan 19, 2024 at 07:40:00PM +0800, sunshaowei01 wrote:
> 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@qq.com>
> ---

Acked-by: Bruce Richardson <bruce.richardson@intel.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] lib/telemetry:fix telemetry conns leak in case of socket write fail
@ 2024-01-19 11:40 sunshaowei01
  2024-01-19 11:54 ` Bruce Richardson
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: sunshaowei01 @ 2024-01-19 11:40 UTC (permalink / raw)
  To: dev; +Cc: ciara.power

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@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)


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-01-19 16:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-19 16:25 [PATCH] lib/telemetry:fix telemetry conns leak in case of socket write fail Shaowei Sun
  -- strict thread matches above, loose matches on Subject: below --
2024-01-19 16:12 sunshaowei01
2024-01-19 11:40 sunshaowei01
2024-01-19 11:54 ` Bruce Richardson
2024-01-19 15:42 ` Power, Ciara
2024-01-19 15:54 ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).