From patchwork Fri Jan 19 16:12:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ShaoWei Sun <1819846787@qq.com> X-Patchwork-Id: 135988 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 08AE643900; Fri, 19 Jan 2024 17:12:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 821644029F; Fri, 19 Jan 2024 17:12:20 +0100 (CET) Received: from out203-205-251-66.mail.qq.com (out203-205-251-66.mail.qq.com [203.205.251.66]) by mails.dpdk.org (Postfix) with ESMTP id 6B75540279 for ; Fri, 19 Jan 2024 17:12:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1705680730; bh=pGICy/8s7IpoKmeLEKbXOz1w0JmxUm6XzrrOnQl0APE=; h=From:To:Cc:Subject:Date; b=J7i08Lg1gbaK5h3kFW4xtITSBPCSnX2Imvw4D0o0PjcDczj/ON+DkllWoWqVJwCZw kFKlFUNgouFSGS4I8uKs2cdQOn4i+84GYRReeI9CDaaxn4L2eZOD26561Q/K3Npftc y0Gdpue+vdAK/zgEGuHrJqhiFyE46ONesGQDAF1I= Received: from localhost.localdomain ([2408:8207:1851:a300:71c7:2812:f2e:cd5c]) by newxmesmtplogicsvrsza10-0.qq.com (NewEsmtp) with SMTP id 308B0249; Sat, 20 Jan 2024 00:12:08 +0800 X-QQ-mid: xmsmtpt1705680728to8vnqo02 Message-ID: X-QQ-XMAILINFO: N2DE1hXbKkmsQuAB4f6z+Jutx5nTl7FWAfIEqdyZxcSvL0aoGv1OMxrM2fjgDa LLOkZGBpkxaSj6jCCkKIBnIpxpMkg5IQh4VjKUwgOwHoIWLa3XaI2kRCWowoM0qDnvSjbkmPTTHh ILGY9s7Y/gQ2Vwn4tZUru5PKa9xXhVAEjH6dzXuKHatLY7XVsjjIDCHiYHeAKWsBVGX7EFs7tI7y nLBhMjyy9W63WK96ePjwBx4bHDFKB28a8+2itmm2sWGh0i0yg6wdOKHFrKHEz4vJ+Hw5L9G5wQAb zaUsE9GjxPhlWe/y5QhZA4k0l4yjbP59BhOLD0S2xUkN0tkikLwkpEpt3Lsoqf6sOg+GbdQF/oIn 8RwsaFnr/N4WPa3I72DLd6xvFfwdW0+/AhzUh184xg/hIOnU5PsGxdeVUXl6GJBmWpOnC7f6G4ZE 3fTDHXxCLe9dh9uVB1pZDIvrRKPRQXF6M9B1KP2Lcxz5yMQ4nIxfq2Ppj8qLQJHkqBLSpBh87qy6 VtW3g66ZB0Us72WcaQjcjPf+DNE0u4WZKLAS6L9a7e/aewqUZlrsdY6pY+AaOJUHjbjKqEgQIYdX qEXa21jom2J5RpnKFiqimzLyxgvx6Mp+ney7uOD4nejd/GzSQJ5j/yFUhf/73dzI6ypWbRr9cyz4 7kIop4FVlGqCKgfTjs8Rb+cXydd39x332LOcufL/Ag9pQ04d23LBdacHi4VNSbSEoyAHZkR0aQXM uXny/+enjJBakdMAvi8MUiksRbhzFJyNVIVQSjGZTr7/JBTEXOu5DHJp48ijib1IkEBU+6RkHLR0 WjJOMawN/cYiZrmXFvY6vxpJncjklNR/DydCqteTnout0FVdtarm3owuBpHgmoOuMVf12xyqzR5d dj4iOALgxNpuv6xMKOR1Kmmc001eVkX+NzhoG4YB1zYwFjmlgehWnwssi7262MLFVA6GG/88ttih 5IKH6NJ14qL3P14ToRfEmOTNX0Qh6T8lsz3+cAS+bQpWrjRFNDlmkrwKnMvTVnwGod16GM9uo7OW d+o2Zgkg== X-QQ-XMRINFO: Mp0Kj//9VHAxr69bL5MkOOs= From: sunshaowei01 <1819846787@qq.com> To: dev@dpdk.org Cc: ciara.power@intel.com, Shaowei Sun <1819846787@qq.com> Subject: [PATCH] lib/telemetry:fix telemetry conns leak in case of socket write fail Date: Sat, 20 Jan 2024 00:12:05 +0800 X-OQ-MSGID: <20240119161205.75888-1-1819846787@qq.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 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 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;