Author: arty
Date: Wed Sep 23 02:45:19 2009
New Revision: 43120
URL:
http://svn.reactos.org/svn/reactos?rev=43120&view=rev
Log:
Allocate a TLS slot once at process join and treat TlsIndex as an alias to it.
Modified:
trunk/reactos/dll/win32/ws2_32_new/inc/ws2_32p.h
trunk/reactos/dll/win32/ws2_32_new/src/dllmain.c
trunk/reactos/dll/win32/ws2_32_new/src/dthread.c
Modified: trunk/reactos/dll/win32/ws2_32_new/inc/ws2_32p.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32_new/inc/w…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32_new/inc/ws2_32p.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32_new/inc/ws2_32p.h [iso-8859-1] Wed Sep 23 02:45:19
2009
@@ -251,9 +251,9 @@
extern HINSTANCE WsDllHandle;
extern HANDLE WsSockHeap;
extern PWAH_HANDLE_TABLE WsSockHandleTable;
-extern DWORD TlsIndex;
extern PWSPROCESS CurrentWsProcess;
extern DWORD GlobalTlsIndex;
+#define TlsIndex GlobalTlsIndex
extern BOOLEAN WsAsyncThreadInitialized;
extern PWS_SOCK_POST_ROUTINE WsSockPostRoutine;
Modified: trunk/reactos/dll/win32/ws2_32_new/src/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32_new/src/d…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32_new/src/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32_new/src/dllmain.c [iso-8859-1] Wed Sep 23 02:45:19
2009
@@ -19,7 +19,7 @@
HANDLE WsSockHeap;
HINSTANCE WsDllHandle;
-DWORD GlobalTlsIndex;
+DWORD GlobalTlsIndex = TLS_OUT_OF_INDEXES;
/* FUNCTIONS *****************************************************************/
@@ -35,7 +35,6 @@
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
-
/* Save DLL Handle */
WsDllHandle = hModule;
@@ -43,8 +42,14 @@
WsSockHeap = GetProcessHeap();
/* TLS Allocation */
- GlobalTlsIndex = TlsAlloc();
- if (GlobalTlsIndex == TLS_OUT_OF_INDEXES) return FALSE;
+ if (GlobalTlsIndex == TLS_OUT_OF_INDEXES)
+ {
+ GlobalTlsIndex = TlsAlloc();
+ if (GlobalTlsIndex == TLS_OUT_OF_INDEXES)
+ {
+ return FALSE;
+ }
+ }
/* Initialize some critical sections */
WsCreateStartupSynchronization();
@@ -61,7 +66,6 @@
break;
case DLL_PROCESS_DETACH:
-
/* Make sure we were initialized */
if (!WsDllHandle) break;
Modified: trunk/reactos/dll/win32/ws2_32_new/src/dthread.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32_new/src/d…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32_new/src/dthread.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/ws2_32_new/src/dthread.c [iso-8859-1] Wed Sep 23 02:45:19
2009
@@ -9,10 +9,6 @@
/* INCLUDES ******************************************************************/
#include "ws2_32.h"
-/* DATA **********************************************************************/
-
-DWORD TlsIndex;
-
/* FUNCTIONS *****************************************************************/
DWORD
@@ -156,16 +152,7 @@
INT ErrorCode = WSASYSCALLFAILURE;
/* Check if we have a valid TLS */
- if (TlsIndex == TLS_OUT_OF_INDEXES)
- {
- /* Set the global one */
- if ((TlsIndex = GlobalTlsIndex) != TLS_OUT_OF_INDEXES)
- {
- /* Success! */
- ErrorCode = ERROR_SUCCESS;
- }
- }
- else
+ if (TlsIndex != TLS_OUT_OF_INDEXES)
{
/* TLS was already OK */
ErrorCode = ERROR_SUCCESS;
@@ -179,12 +166,6 @@
WSAAPI
WsThreadCleanup(VOID)
{
- /* Check if we have a valid TLS */
- if (TlsIndex != TLS_OUT_OF_INDEXES)
- {
- /* We do, invalidate it */
- TlsIndex = TLS_OUT_OF_INDEXES;
- }
}
DWORD
@@ -250,6 +231,7 @@
{
/* Delete it */
WsThreadDelete(Thread);
+ TlsSetValue(TlsIndex, 0);
}
}
}