From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0CC4C43925; Mon, 22 Jan 2024 08:39:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 878DE402B8; Mon, 22 Jan 2024 08:39:36 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 31EDC4028B for ; Mon, 22 Jan 2024 08:39:35 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TJMXS40cXzsWL9; Mon, 22 Jan 2024 15:38:32 +0800 (CST) Received: from dggpeml500024.china.huawei.com (unknown [7.185.36.10]) by mail.maildlp.com (Postfix) with ESMTPS id A14AB1404FC; Mon, 22 Jan 2024 15:39:32 +0800 (CST) Received: from [10.67.121.161] (10.67.121.161) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 22 Jan 2024 15:39:32 +0800 Subject: Re: [PATCH] [v2]lib/telemetry:fix telemetry conns leak in case of socket write fail To: Shaowei Sun <1819846787@qq.com>, CC: References: From: fengchengwen Message-ID: <25548a81-75f9-b391-0644-1f2ec7181c27@huawei.com> Date: Mon, 22 Jan 2024 15:39:32 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.121.161] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500024.china.huawei.com (7.185.36.10) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Acked-by: Chengwen Feng On 2024/1/20 16:58, Shaowei Sun 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 > > 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; >