From ece8ee23a93b48620c4611016e73cb8ae1e10117 Mon Sep 17 00:00:00 2001 From: zhuxiantao99 Date: Sat, 12 Oct 2024 10:58:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AF=E6=80=BB=E7=BA=BF=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=81=B6=E7=8E=B0=E6=97=B6=E5=BA=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhuxiantao99 --- samgr/adapter/posix/thread_adapter.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/samgr/adapter/posix/thread_adapter.c b/samgr/adapter/posix/thread_adapter.c index adf7cb3..b3da820 100644 --- a/samgr/adapter/posix/thread_adapter.c +++ b/samgr/adapter/posix/thread_adapter.c @@ -98,10 +98,16 @@ int THREAD_Total(void) void *THREAD_GetThreadLocal(void) { + if (g_localKey == -1) { + (void) pthread_once(&g_localKeyOnce, KeyCreate); + } return pthread_getspecific(g_localKey); } void THREAD_SetThreadLocal(const void *local) { + if (g_localKey == -1) { + (void) pthread_once(&g_localKeyOnce, KeyCreate); + } pthread_setspecific(g_localKey, local); } -- Gitee