Jacek Caban (@jacek) commented about dlls/jscript/jscript_main.c:
DisableThreadLibraryCalls(hInstDLL); jscript_hinstance = hInstDLL;
if(!init_strings())
jscript_tls = TlsAlloc();
case DLL_PROCESS_DETACH: if (lpv) break; if (dispatch_typeinfo) ITypeInfo_Release(dispatch_typeinfo);if(jscript_tls == TLS_OUT_OF_INDEXES || !init_strings()) return FALSE; break;
if(jscript_tls != TLS_OUT_OF_INDEXES) TlsFree(jscript_tls); free_strings();
break;
- case DLL_THREAD_DETACH:
free_thread_data();
break;
This won't work because we use `DisableThreadLibraryCalls` for jscript.dll. To avoid enabling thread library calls, you could make thread data ref-counted. I'd also consider moving thread_id from JScript struct to thread data struct and store a pointer to that in JScript struct. `script_ctx_t` could also store a pointer, which would avoid the need for getter.