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 45BC0A0C48 for ; Wed, 16 Jun 2021 08:52:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0CD7F40140; Wed, 16 Jun 2021 08:52:55 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 91C2840140 for ; Wed, 16 Jun 2021 08:52:53 +0200 (CEST) IronPort-SDR: zgjUxig3/uVKShtoW9F0Z5zHl6d5jW9m7qcOMkYPpvaUT48jlPLpSW4OzkgL7HkFrHrLJaMzLq gtlsSJ8Vfx4g== X-IronPort-AV: E=McAfee;i="6200,9189,10016"; a="269975188" X-IronPort-AV: E=Sophos;i="5.83,277,1616482800"; d="scan'208";a="269975188" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2021 23:52:52 -0700 IronPort-SDR: vfDhlGd6AyGKeDRaH6mL/9CGXCMsdWrkUL30PukeX2LASQC2JInTUfhQfGW1D14OXvhqQmDKgg RcOnOmXsh8kQ== X-IronPort-AV: E=Sophos;i="5.83,277,1616482800"; d="scan'208";a="421387594" Received: from shwdenpg235.ccr.corp.intel.com ([10.240.182.60]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2021 23:52:49 -0700 From: Alvin Zhang To: christian.ehrhardt@canonical.com, LingliX.Chen@intel.com Cc: Alvin Zhang , stable@dpdk.org Date: Wed, 16 Jun 2021 14:52:41 +0800 Message-Id: <20210616065241.13352-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] 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 calling thread returns from the function "rte_ctrl_thread_create", the newly created thread may have ran and exited for "thread_status" was 0. This patch puts setting "thread_status" status before creating new thread. Fixes: 8877ac688b52 ("telemetry: introduce infrastructure") Cc: stable@dpdk.org Signed-off-by: Alvin Zhang --- 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