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 E3B69A0C50 for ; Mon, 12 Jul 2021 10:56:10 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AC70B40685; Mon, 12 Jul 2021 10:56:10 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 009E640685 for ; Mon, 12 Jul 2021 10:56:08 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10042"; a="295589123" X-IronPort-AV: E=Sophos;i="5.84,232,1620716400"; d="scan'208";a="295589123" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2021 01:56:07 -0700 X-IronPort-AV: E=Sophos;i="5.84,232,1620716400"; d="scan'208";a="561685182" Received: from shwdenpg235.ccr.corp.intel.com ([10.253.106.22]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2021 01:56:05 -0700 From: Alvin Zhang To: christian.ehrhardt@canonical.com Cc: Alvin Zhang , stable@dpdk.org Date: Mon, 12 Jul 2021 16:56:00 +0800 Message-Id: <20210712085600.16968-1-alvinx.zhang@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v2] telemetry: fix race in telemetry control thread creation X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Alvin Zhang Before the caller returns from function "rte_ctrl_thread_create", the newly created thread may have ran, and because the thread control flag was not set before, the new thread may exit soon. This is not what the developer expected. This patch puts the setting thread control flag to the place that before creating new thread. Fixes: 8877ac688b52 ("telemetry: introduce infrastructure") Cc: stable@dpdk.org Signed-off-by: Alvin Zhang --- v2: update commit log --- lib/librte_telemetry/rte_telemetry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_telemetry/rte_telemetry.c b/lib/librte_telemetry/rte_telemetry.c index eb20cc6..98d5f91 100644 --- a/lib/librte_telemetry/rte_telemetry.c +++ b/lib/librte_telemetry/rte_telemetry.c @@ -1005,10 +1005,10 @@ struct json_data { } TAILQ_INIT(&static_telemetry->client_list_head); + static_telemetry->thread_status = 1; ret = rte_ctrl_thread_create(&static_telemetry->thread_id, telemetry_ctrl_thread, &attr, rte_telemetry_run_thread_func, (void *)static_telemetry); - static_telemetry->thread_status = 1; if (ret < 0) { ret = rte_telemetry_cleanup(); -- 1.8.3.1