From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6BC73A04B7; Tue, 13 Oct 2020 18:28:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4BBE31DB8B; Tue, 13 Oct 2020 18:28:31 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 33D3B1DB8B for ; Tue, 13 Oct 2020 18:28:29 +0200 (CEST) IronPort-SDR: g3CbxseR6lJOI9MBcTxVixlkOq9Gj8U7W8j2bw6Fpnlevi0oGxB2b7j1cQual5mrOMjiO7hPfR EIK/+DJekkvg== X-IronPort-AV: E=McAfee;i="6000,8403,9773"; a="165150604" X-IronPort-AV: E=Sophos;i="5.77,371,1596524400"; d="scan'208";a="165150604" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2020 09:28:25 -0700 IronPort-SDR: xixZu45xnSyDSZo8SMLujRxVLWVoRic8dYxttV21csZVDmm3WwhYYe01fL2i8qOZ8D6iCXcK4t KF4OMf6l0R+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,371,1596524400"; d="scan'208";a="345322568" Received: from silpixa00400355.ir.intel.com (HELO silpixa00400355.ger.corp.intel.com) ([10.237.222.239]) by fmsmga004.fm.intel.com with ESMTP; 13 Oct 2020 09:28:24 -0700 From: Ciara Power To: dev@dpdk.org Cc: Ciara Power , Kevin Laatz Date: Tue, 13 Oct 2020 17:28:20 +0100 Message-Id: <20201013162820.6544-1-ciara.power@intel.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] test/telemetry: fix error handling for socket X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When the socket connection failed, an error was printed to screen but the function did not return an error, and continued to try read from the socket. This is now corrected to close the socket and return -1 when the connection fails. Fixes: bd78cf693ebd ("test/telemetry: add unit tests for data to JSON") Signed-off-by: Ciara Power --- app/test/test_telemetry_data.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/test/test_telemetry_data.c b/app/test/test_telemetry_data.c index 7a31e68a78..00326867b6 100644 --- a/app/test/test_telemetry_data.c +++ b/app/test/test_telemetry_data.c @@ -319,9 +319,12 @@ connect_to_socket(void) "%s/dpdk_telemetry.%s", rte_eal_get_runtime_dir(), TELEMETRY_VERSION); if (connect(sock, (struct sockaddr *) &telem_addr, - sizeof(telem_addr)) < 0) + sizeof(telem_addr)) < 0) { printf("\n%s: Error connecting to socket: %s\n", __func__, strerror(errno)); + close(sock); + return -1; + } bytes = read(sock, buf, sizeof(buf) - 1); if (bytes < 0) { -- 2.22.0