Skip to content

Commit 18e7e0b

Browse files
committed
HACK/base: avoid recursion in TSD cleanup
Windows does not have the same semantics for the thread clean up when using FLS (TLS does not support callbacks on destructor). Simply wipe out everything on attempt one.
1 parent 2d87452 commit 18e7e0b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

CoreFoundation/Base.subproj/CFPlatform.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,14 +678,19 @@ static void __CFTSDFinalize(void *arg) {
678678
table->destructors[i]((void *)(old));
679679
}
680680
}
681-
681+
682+
#if _POSIX_THREADS
682683
if (table->destructorCount == PTHREAD_DESTRUCTOR_ITERATIONS - 1) { // On PTHREAD_DESTRUCTOR_ITERATIONS-1 call, destroy our data
683684
free(table);
684685

685686
// Now if the destructor is called again we will take the shortcut at the beginning of this function.
686687
__CFTSDSetSpecific(CF_TSD_BAD_PTR);
687688
return;
688689
}
690+
#else
691+
free(table);
692+
__CFTSDSetSpecific(CF_TSD_BAD_PTR);
693+
#endif
689694
}
690695

691696
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI

0 commit comments

Comments
 (0)