CoState should be thread local (move pUnkState into TLS)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ChangeLog:
CoState storage should be thread local
Index: dlls/ole32/compobj.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/compobj.c,v
retrieving revision 1.75
diff -u -r1.75 compobj.c
--- dlls/ole32/compobj.c	13 May 2003 22:14:30 -0000	1.75
+++ dlls/ole32/compobj.c	14 Jun 2003 21:50:27 -0000
@@ -60,6 +60,9 @@
 
 const CLSID CLSID_StdGlobalInterfaceTable = { 0x00000323, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46} };
 
+static DWORD dwUnkStateSlot = 0; /* TLS slot used to the store the UnkState, see CoSetState */
+
+
 
 /*****************************************************************************
  * Apartment management stuff
@@ -326,7 +328,8 @@
      */
     TRACE("() - Initializing the COM libraries\n");
 
-
+    /* Allocate UnkState TLS slot, for CoSetState/CoGetState */
+    dwUnkStateSlot = TlsAlloc();
     RunningObjectTableImpl_Initialize();
 
     hr = S_OK;
@@ -362,6 +365,9 @@
      */
     TRACE("() - Releasing the COM libraries\n");
 
+    /* Release the UnkState TLS slot */
+    TlsFree(dwUnkStateSlot);
+
     RunningObjectTableImpl_UnInitialize();
     /*
      * Release the references to the registered class objects.
@@ -1743,7 +1749,6 @@
     return 0;
 }
 
-static IUnknown * pUnkState = 0; /* FIXME: thread local */
 static int nStatCounter = 0;	 /* global */
 static HMODULE hOleAut32 = 0;	 /* global */
 
@@ -1754,6 +1759,7 @@
  */
 HRESULT WINAPI CoGetState(IUnknown ** ppv)
 {
+	IUnknown *pUnkState = TlsGetValue(dwUnkStateSlot);
 	FIXME("\n");
 
 	if(pUnkState) {
@@ -1774,8 +1780,10 @@
  */
 HRESULT WINAPI CoSetState(IUnknown * pv)
 {
-	FIXME("(%p),stub!\n", pv);
+	IUnknown *pUnkState = TlsGetValue(dwUnkStateSlot);
 
+	FIXME("(%p),stub!\n", pv);
+	
 	if (pv) {
 	    IUnknown_AddRef(pv);
 	    nStatCounter++;
@@ -1783,12 +1791,12 @@
 	}
 
 	if (pUnkState) {
-	    TRACE("-- release %p now\n", pUnkState);
+	    ERR("-- release %p now\n", pUnkState);
 	    IUnknown_Release(pUnkState);
 	    nStatCounter--;
 	    if (!nStatCounter) FreeLibrary(hOleAut32);
 	}
-	pUnkState = pv;
+	TlsSetValue(dwUnkStateSlot, pv);
 	return S_OK;
 }
 

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux