Skip to content

[SR-6420] Ensure that the pthread_key is initialised once #1325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CoreFoundation/Base.subproj/CFPlatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,16 @@ CF_PRIVATE void __CFFinalizeWindowsThreadData() {
#endif

static pthread_key_t __CFTSDIndexKey;
static pthread_once_t __CFTSDIndexKey_once = PTHREAD_ONCE_INIT;

CF_PRIVATE void __CFTSDInitialize() {
CF_PRIVATE void __CFTSDInitializeOnce() {
(void)pthread_key_create(&__CFTSDIndexKey, __CFTSDFinalize);
}

CF_PRIVATE void __CFTSDInitialize() {
(void)pthread_once(&__CFTSDIndexKey_once, __CFTSDInitializeOnce);
}

static void __CFTSDSetSpecific(void *arg) {
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI
pthread_setspecific(__CFTSDIndexKey, arg);
Expand Down