Properly implement DllCanUnloadNow ref counting.

This commit is contained in:
James Hawkins 2005-02-03 19:38:37 +00:00 committed by Alexandre Julliard
parent 78d096c151
commit bbc081e834
4 changed files with 35 additions and 5 deletions

View File

@ -82,6 +82,8 @@ static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface)
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
URLMON_LockModule();
return refCount;
}
@ -96,6 +98,9 @@ static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
if (!refCount){
HeapFree(GetProcessHeap(),0,This);
}
URLMON_UnlockModule();
return refCount;
}
@ -242,6 +247,8 @@ static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManager* iface)
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
URLMON_LockModule();
return refCount;
}
@ -257,6 +264,9 @@ static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManager* iface)
if(!refCount)
HeapFree(GetProcessHeap(), 0, This);
URLMON_UnlockModule();
return refCount;
}

View File

@ -107,6 +107,8 @@ static ULONG WINAPI URLMonikerImpl_AddRef(IMoniker* iface)
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
URLMON_LockModule();
return refCount;
}
@ -126,6 +128,8 @@ static ULONG WINAPI URLMonikerImpl_Release(IMoniker* iface)
HeapFree(GetProcessHeap(),0,This);
}
URLMON_UnlockModule();
return refCount;
}

View File

@ -37,6 +37,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
LONG URLMON_refCount = 0;
HINSTANCE URLMON_hInstance = 0;
/***********************************************************************
@ -76,9 +78,7 @@ HRESULT WINAPI URLMON_DllInstall(BOOL bInstall, LPCWSTR cmdline)
*/
HRESULT WINAPI URLMON_DllCanUnloadNow(void)
{
FIXME("(void): stub\n");
return S_FALSE;
return URLMON_refCount != 0 ? S_FALSE : S_OK;
}
@ -125,6 +125,8 @@ CF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
static ULONG WINAPI CF_AddRef(LPCLASSFACTORY iface)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
URLMON_LockModule();
return InterlockedIncrement(&This->ref);
}
@ -137,6 +139,8 @@ static ULONG WINAPI CF_Release(LPCLASSFACTORY iface)
if (ref == 0)
HeapFree(GetProcessHeap(), 0, This);
URLMON_UnlockModule();
return ref;
}
@ -160,8 +164,13 @@ static HRESULT WINAPI CF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
static HRESULT WINAPI CF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
{
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
FIXME("(%p)->(%d),stub!\n",This,dolock);
TRACE("(%d)\n", dolock);
if (dolock)
URLMON_LockModule();
else
URLMON_UnlockModule();
return S_OK;
}

View File

@ -28,6 +28,13 @@ extern HINSTANCE URLMON_hInstance;
extern HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
/**********************************************************************
* Dll lifetime tracking declaration for urlmon.dll
*/
extern LONG URLMON_refCount;
static inline void URLMON_LockModule() { InterlockedIncrement( &URLMON_refCount ); }
static inline void URLMON_UnlockModule() { InterlockedDecrement( &URLMON_refCount ); }
#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
#endif /* __WINE_URLMON_MAIN_H */