URLMON: Better locking module

Jacek Caban jack at itma.pwr.wroc.pl
Fri Jul 1 16:52:36 CDT 2005


Changelog:
    Better locking module
-------------- next part --------------
Index: dlls/urlmon/sec_mgr.c
===================================================================
RCS file: /home/wine/wine/dlls/urlmon/sec_mgr.c,v
retrieving revision 1.6
diff -u -p -r1.6 sec_mgr.c
--- dlls/urlmon/sec_mgr.c	6 Jun 2005 19:50:36 -0000	1.6
+++ dlls/urlmon/sec_mgr.c	1 Jul 2005 21:46:44 -0000
@@ -82,8 +82,6 @@ static ULONG WINAPI SecManagerImpl_AddRe
 
     TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
 
-    URLMON_LockModule();
-
     return refCount;
 }
 
@@ -97,10 +95,9 @@ static ULONG WINAPI SecManagerImpl_Relea
     /* destroy the object if there's no more reference on it */
     if (!refCount){
         HeapFree(GetProcessHeap(),0,This);
+        URLMON_UnlockModule();
     }
 
-    URLMON_UnlockModule();
-
     return refCount;
 }
 
@@ -201,6 +198,9 @@ HRESULT SecManagerImpl_Construct(IUnknow
     This->ref          = 1;
 
     *ppobj = This;
+
+    URLMON_LockModule();
+
     return S_OK;
 }
 
@@ -247,8 +247,6 @@ static ULONG WINAPI ZoneMgrImpl_AddRef(I
 
     TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
 
-    URLMON_LockModule();
-
     return refCount;
 }
 
@@ -262,10 +260,10 @@ static ULONG WINAPI ZoneMgrImpl_Release(
 
     TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
 
-    if(!refCount)
+    if(!refCount) {
         HeapFree(GetProcessHeap(), 0, This);
-
-    URLMON_UnlockModule();
+        URLMON_UnlockModule();
+    }
     
     return refCount;
 }
@@ -456,6 +454,8 @@ HRESULT ZoneMgrImpl_Construct(IUnknown *
     ret->lpVtbl = &ZoneMgrImplVtbl;
     ret->ref = 1;
     *ppobj = (IInternetZoneManager*)ret;
+
+    URLMON_LockModule();
 
     return S_OK;
 }
Index: dlls/urlmon/umon.c
===================================================================
RCS file: /home/wine/wine/dlls/urlmon/umon.c,v
retrieving revision 1.55
diff -u -p -r1.55 umon.c
--- dlls/urlmon/umon.c	6 Jun 2005 19:50:36 -0000	1.55
+++ dlls/urlmon/umon.c	1 Jul 2005 21:46:45 -0000
@@ -340,8 +340,6 @@ static ULONG WINAPI URLMonikerImpl_AddRe
 
     TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
 
-    URLMON_LockModule();
-
     return refCount;
 }
 
@@ -359,9 +357,9 @@ static ULONG WINAPI URLMonikerImpl_Relea
     if (!refCount) {
         HeapFree(GetProcessHeap(),0,This->URLName);
         HeapFree(GetProcessHeap(),0,This);
-    }
 
-    URLMON_UnlockModule();
+        URLMON_UnlockModule();
+    }
 
     return refCount;
 }
@@ -1169,6 +1167,8 @@ static HRESULT URLMonikerImpl_Construct(
     }
     else
         strcpyW(This->URLName,lpszURLName);
+
+    URLMON_LockModule();
 
     return S_OK;
 }
Index: dlls/urlmon/urlmon_main.c
===================================================================
RCS file: /home/wine/wine/dlls/urlmon/urlmon_main.c,v
retrieving revision 1.27
diff -u -p -r1.27 urlmon_main.c
--- dlls/urlmon/urlmon_main.c	21 Jun 2005 09:44:47 -0000	1.27
+++ dlls/urlmon/urlmon_main.c	1 Jul 2005 21:46:45 -0000
@@ -125,8 +125,6 @@ CF_QueryInterface(LPCLASSFACTORY iface,R
 static ULONG WINAPI CF_AddRef(LPCLASSFACTORY iface)
 {
     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
-    URLMON_LockModule();
-    
     return InterlockedIncrement(&This->ref);
 }
 
@@ -136,10 +134,10 @@ static ULONG WINAPI CF_Release(LPCLASSFA
 
     ULONG ref = InterlockedDecrement(&This->ref);
 
-    if (ref == 0)
-	HeapFree(GetProcessHeap(), 0, This);
-
-    URLMON_UnlockModule();
+    if (ref == 0) {
+        HeapFree(GetProcessHeap(), 0, This);
+        URLMON_UnlockModule();
+    }
 
     return ref;
 }
@@ -229,10 +227,12 @@ DWORD WINAPI URLMON_DllGetClassObject(RE
 
     factory->ITF_IClassFactory.lpVtbl = &CF_Vtbl;
     factory->ref = 1;
-
     factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
 
     *ppv = &(factory->ITF_IClassFactory);
+
+    URLMON_LockModule();
+
     return S_OK;
 }


More information about the wine-patches mailing list