From 7e4af0f60b71a4384301a360ea8cac411943173f Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 14 May 2005 11:09:21 +0000 Subject: [PATCH] Store the winsock per-thread data in NtCurrentTeb()->WinSockData instead of using TlsAlloc. --- dlls/winsock/socket.c | 10 ++++------ include/thread.h | 20 ++++++++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/dlls/winsock/socket.c b/dlls/winsock/socket.c index 5de9b5aa3f..c4f652b48d 100644 --- a/dlls/winsock/socket.c +++ b/dlls/winsock/socket.c @@ -222,7 +222,6 @@ struct per_thread_data int pe_len; }; -static DWORD tls_index = TLS_OUT_OF_INDEXES; /* TLS index for per-thread data */ static INT num_startup; /* reference counter */ static FARPROC blocking_hook = WSA_DefaultBlockingHook; @@ -405,19 +404,19 @@ static int _get_sock_error(SOCKET s, unsigned int bit) 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 */ if (!ptb) { ptb = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ptb) ); - TlsSetValue( tls_index, ptb ); + NtCurrentTeb()->WinSockData = ptb; } return ptb; } 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; @@ -430,6 +429,7 @@ static void free_per_thread_data(void) ptb->pe_buffer = NULL; HeapFree( GetProcessHeap(), 0, ptb ); + NtCurrentTeb()->WinSockData = NULL; } /*********************************************************************** @@ -440,11 +440,9 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad) TRACE("%p 0x%lx %p\n", hInstDLL, fdwReason, fImpLoad); switch (fdwReason) { case DLL_PROCESS_ATTACH: - tls_index = TlsAlloc(); break; case DLL_PROCESS_DETACH: free_per_thread_data(); - TlsFree( tls_index ); num_startup = 0; break; case DLL_THREAD_DETACH: diff --git a/include/thread.h b/include/thread.h index baaf6c1383..697c417c8d 100644 --- a/include/thread.h +++ b/include/thread.h @@ -110,12 +110,20 @@ typedef struct _TEB PVOID DeallocationStack; /* -2- e0c Base of the stack */ LPVOID TlsSlots[64]; /* -2- e10 Thread local storage */ LIST_ENTRY TlsLinks; /* -2- f10 */ - DWORD pad8[1]; /* --n f18 */ - PVOID ReservedForNtRpc; /* -2- f1c used by rpcrt4 */ - DWORD pad9[24]; /* --n f20 */ - PVOID ReservedForOle; /* -2- f80 used by ole32 (IErrorInfo*) */ - PVOID pad10[4]; /* --n f84 */ - PVOID *TlsExpansionSlots; /* -2- f94 */ + PVOID Vdm; /* f18 */ + PVOID ReservedForNtRpc; /* f1c */ + PVOID DbgSsReserved[2]; /* f20 */ + ULONG HardErrorDisabled; /* f28 */ + PVOID Instrumentation[16]; /* f2c */ + 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; #endif /* WINE_TEB_DEFINED */ -- 2.32.0.93.g670b81a890