*Dll_entry: Call SysInitMultiThreading to allocate TlsKey if not yet done

git-svn-id: trunk@17892 -
This commit is contained in:
pierre 2011-07-01 10:08:40 +00:00
parent 1339c66ec9
commit 128e2e9cc5

View File

@ -52,6 +52,8 @@ function Dll_entry{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}(const info : TEntry
begin begin
if Win32GetCurrentThreadId <> MainThreadIdWin32 then if Win32GetCurrentThreadId <> MainThreadIdWin32 then
begin begin
{ Initialize multithreading if not done }
SysInitMultithreading;
{ Allocate Threadvars } { Allocate Threadvars }
SysAllocateThreadVars; SysAllocateThreadVars;
@ -76,8 +78,8 @@ function Dll_entry{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}(const info : TEntry
DLL_PROCESS_DETACH : DLL_PROCESS_DETACH :
begin begin
Dll_entry:=true; { return value is ignored } Dll_entry:=true; { return value is ignored }
if MainThreadIDWin32=0 then // already been here. if MainThreadIDWin32=0 then // already been here.
exit; exit;
If SetJmp(DLLBuf) = 0 then If SetJmp(DLLBuf) = 0 then
FPC_Do_Exit; FPC_Do_Exit;
if assigned(Dll_Process_Detach_Hook) then if assigned(Dll_Process_Detach_Hook) then
@ -86,7 +88,7 @@ function Dll_entry{$ifdef FPC_HAS_INDIRECT_MAIN_INFORMATION}(const info : TEntry
DoneThread; DoneThread;
{ Free TLS resources used by ThreadVars } { Free TLS resources used by ThreadVars }
SysFiniMultiThreading; SysFiniMultiThreading;
MainThreadIDWin32:=0; MainThreadIDWin32:=0;
end; end;
end; end;
end; end;