Commit 7e4af0f6 authored by Alexandre Julliard's avatar Alexandre Julliard

Store the winsock per-thread data in NtCurrentTeb()->WinSockData

instead of using TlsAlloc.
parent 55d449e4
...@@ -222,7 +222,6 @@ struct per_thread_data ...@@ -222,7 +222,6 @@ struct per_thread_data
int pe_len; int pe_len;
}; };
static DWORD tls_index = TLS_OUT_OF_INDEXES; /* TLS index for per-thread data */
static INT num_startup; /* reference counter */ static INT num_startup; /* reference counter */
static FARPROC blocking_hook = WSA_DefaultBlockingHook; static FARPROC blocking_hook = WSA_DefaultBlockingHook;
...@@ -405,19 +404,19 @@ static int _get_sock_error(SOCKET s, unsigned int bit) ...@@ -405,19 +404,19 @@ static int _get_sock_error(SOCKET s, unsigned int bit)
static struct per_thread_data *get_per_thread_data(void) static struct per_thread_data *get_per_thread_data(void)
{ {
struct per_thread_data * ptb = TlsGetValue( tls_index ); struct per_thread_data * ptb = NtCurrentTeb()->WinSockData;
/* lazy initialization */ /* lazy initialization */
if (!ptb) if (!ptb)
{ {
ptb = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ptb) ); ptb = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ptb) );
TlsSetValue( tls_index, ptb ); NtCurrentTeb()->WinSockData = ptb;
} }
return ptb; return ptb;
} }
static void free_per_thread_data(void) static void free_per_thread_data(void)
{ {
struct per_thread_data * ptb = TlsGetValue( tls_index ); struct per_thread_data * ptb = NtCurrentTeb()->WinSockData;
if (!ptb) return; if (!ptb) return;
...@@ -430,6 +429,7 @@ static void free_per_thread_data(void) ...@@ -430,6 +429,7 @@ static void free_per_thread_data(void)
ptb->pe_buffer = NULL; ptb->pe_buffer = NULL;
HeapFree( GetProcessHeap(), 0, ptb ); HeapFree( GetProcessHeap(), 0, ptb );
NtCurrentTeb()->WinSockData = NULL;
} }
/*********************************************************************** /***********************************************************************
...@@ -440,11 +440,9 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad) ...@@ -440,11 +440,9 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
TRACE("%p 0x%lx %p\n", hInstDLL, fdwReason, fImpLoad); TRACE("%p 0x%lx %p\n", hInstDLL, fdwReason, fImpLoad);
switch (fdwReason) { switch (fdwReason) {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
tls_index = TlsAlloc();
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
free_per_thread_data(); free_per_thread_data();
TlsFree( tls_index );
num_startup = 0; num_startup = 0;
break; break;
case DLL_THREAD_DETACH: case DLL_THREAD_DETACH:
......
...@@ -110,12 +110,20 @@ typedef struct _TEB ...@@ -110,12 +110,20 @@ typedef struct _TEB
PVOID DeallocationStack; /* -2- e0c Base of the stack */ PVOID DeallocationStack; /* -2- e0c Base of the stack */
LPVOID TlsSlots[64]; /* -2- e10 Thread local storage */ LPVOID TlsSlots[64]; /* -2- e10 Thread local storage */
LIST_ENTRY TlsLinks; /* -2- f10 */ LIST_ENTRY TlsLinks; /* -2- f10 */
DWORD pad8[1]; /* --n f18 */ PVOID Vdm; /* f18 */
PVOID ReservedForNtRpc; /* -2- f1c used by rpcrt4 */ PVOID ReservedForNtRpc; /* f1c */
DWORD pad9[24]; /* --n f20 */ PVOID DbgSsReserved[2]; /* f20 */
PVOID ReservedForOle; /* -2- f80 used by ole32 (IErrorInfo*) */ ULONG HardErrorDisabled; /* f28 */
PVOID pad10[4]; /* --n f84 */ PVOID Instrumentation[16]; /* f2c */
PVOID *TlsExpansionSlots; /* -2- f94 */ PVOID WinSockData; /* f6c */
ULONG GdiBatchCount; /* f70 */
ULONG Spare2; /* f74 */
ULONG Spare3; /* f78 */
ULONG Spare4; /* f7c */
PVOID ReservedForOle; /* f80 */
ULONG WaitingOnLoaderLock; /* f84 */
PVOID Reserved5[3]; /* f88 */
PVOID *TlsExpansionSlots; /* f94 */
} TEB; } TEB;
#endif /* WINE_TEB_DEFINED */ #endif /* WINE_TEB_DEFINED */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment