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 247CCA0C4A for ; Tue, 13 Jul 2021 08:16:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D44D54069E; Tue, 13 Jul 2021 08:16:13 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 382B54069E for ; Tue, 13 Jul 2021 08:16:11 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10043"; a="207088121" X-IronPort-AV: E=Sophos;i="5.84,235,1620716400"; d="scan'208";a="207088121" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2021 23:16:10 -0700 X-IronPort-AV: E=Sophos;i="5.84,235,1620716400"; d="scan'208";a="561994349" 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 23:16:07 -0700 From: Alvin Zhang To: christian.ehrhardt@canonical.com, LingliX.Chen@intel.com, YuX.Jiang@intel.com, ciara.power@intel.com, harry.van.haaren@intel.com Cc: Alvin Zhang , stable@dpdk.org Date: Tue, 13 Jul 2021 14:16:02 +0800 Message-Id: <20210713061602.13064-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 v3] 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. Reported-at: https://bugs.dpdk.org/show_bug.cgi?id=731 Fixes: 8877ac688b52 ("telemetry: introduce infrastructure") Cc: stable@dpdk.org Signed-off-by: Alvin Zhang --- v2, v3: 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