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 33F22A0C4A for ; Tue, 13 Jul 2021 08:41:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F21954069E; Tue, 13 Jul 2021 08:41:46 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id E2A714069E for ; Tue, 13 Jul 2021 08:41:45 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10043"; a="208291056" X-IronPort-AV: E=Sophos;i="5.84,235,1620716400"; d="scan'208";a="208291056" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2021 23:41:44 -0700 X-IronPort-AV: E=Sophos;i="5.84,235,1620716400"; d="scan'208";a="493715505" Received: from shwdenpg235.ccr.corp.intel.com ([10.253.106.22]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2021 23:41:42 -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:41:37 +0800 Message-Id: <20210713064137.12488-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 v4] 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" 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 v4: update email address --- 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