Skip to content

Commit a19edaf

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 d6f1f01 commit a19edaf

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
@@ -677,14 +677,19 @@ static void __CFTSDFinalize(void *arg) {
677677
table->destructors[i]((void *)(old));
678678
}
679679
}
680-
680+
681+
#if _POSIX_THREADS
681682
if (table->destructorCount == PTHREAD_DESTRUCTOR_ITERATIONS - 1) { // On PTHREAD_DESTRUCTOR_ITERATIONS-1 call, destroy our data
682683
free(table);
683684

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

690695
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI

0 commit comments

Comments
 (0)