mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 15:26:51 +00:00
Sync to Wine-20050211
James Hawkins <truiken@gmail.com> - Properly implement DllCanUnloadNow ref counting. - Use only stored result of Interlocked* in AddRef/Release. - Expand TRACEs to display the ref count. svn path=/trunk/; revision=13561
This commit is contained in:
parent
05ba38b081
commit
e2e83d6591
4 changed files with 55 additions and 27 deletions
|
@ -78,25 +78,30 @@ static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* if
|
||||||
static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface)
|
static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface)
|
||||||
{
|
{
|
||||||
SecManagerImpl *This = (SecManagerImpl *)iface;
|
SecManagerImpl *This = (SecManagerImpl *)iface;
|
||||||
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
||||||
|
|
||||||
TRACE("(%p)\n",This);
|
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
|
||||||
|
|
||||||
return InterlockedIncrement(&This->ref);
|
URLMON_LockModule();
|
||||||
|
|
||||||
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
|
static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
|
||||||
{
|
{
|
||||||
SecManagerImpl *This = (SecManagerImpl *)iface;
|
SecManagerImpl *This = (SecManagerImpl *)iface;
|
||||||
ULONG ref;
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
||||||
TRACE("(%p)\n",This);
|
|
||||||
|
|
||||||
ref = InterlockedDecrement(&This->ref);
|
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
|
||||||
|
|
||||||
/* destroy the object if there's no more reference on it */
|
/* destroy the object if there's no more reference on it */
|
||||||
if (ref==0){
|
if (!refCount){
|
||||||
HeapFree(GetProcessHeap(),0,This);
|
HeapFree(GetProcessHeap(),0,This);
|
||||||
}
|
}
|
||||||
return ref;
|
|
||||||
|
URLMON_UnlockModule();
|
||||||
|
|
||||||
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManager *iface,
|
static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManager *iface,
|
||||||
|
@ -238,10 +243,13 @@ static HRESULT WINAPI ZoneMgrImpl_QueryInterface(IInternetZoneManager* iface, RE
|
||||||
static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManager* iface)
|
static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManager* iface)
|
||||||
{
|
{
|
||||||
ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
|
ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
|
||||||
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
||||||
|
|
||||||
TRACE("(%p) was %lu\n", This, This->ref);
|
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
|
||||||
|
|
||||||
return InterlockedIncrement(&This->ref);
|
URLMON_LockModule();
|
||||||
|
|
||||||
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
@ -250,15 +258,16 @@ static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManager* iface)
|
||||||
static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManager* iface)
|
static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManager* iface)
|
||||||
{
|
{
|
||||||
ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
|
ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
|
||||||
ULONG ref;
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
||||||
|
|
||||||
TRACE("(%p) was %lu\n", This, This->ref);
|
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
|
||||||
ref = InterlockedDecrement(&This->ref);
|
|
||||||
|
|
||||||
if(!ref)
|
if(!refCount)
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
|
|
||||||
return ref;
|
URLMON_UnlockModule();
|
||||||
|
|
||||||
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
|
|
@ -103,10 +103,13 @@ static HRESULT WINAPI URLMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,
|
||||||
static ULONG WINAPI URLMonikerImpl_AddRef(IMoniker* iface)
|
static ULONG WINAPI URLMonikerImpl_AddRef(IMoniker* iface)
|
||||||
{
|
{
|
||||||
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
||||||
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
||||||
|
|
||||||
TRACE("(%p)\n",This);
|
TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1);
|
||||||
|
|
||||||
return InterlockedIncrement(&This->ref);
|
URLMON_LockModule();
|
||||||
|
|
||||||
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -115,19 +118,19 @@ static ULONG WINAPI URLMonikerImpl_AddRef(IMoniker* iface)
|
||||||
static ULONG WINAPI URLMonikerImpl_Release(IMoniker* iface)
|
static ULONG WINAPI URLMonikerImpl_Release(IMoniker* iface)
|
||||||
{
|
{
|
||||||
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
URLMonikerImpl *This = (URLMonikerImpl *)iface;
|
||||||
ULONG ref;
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
||||||
|
|
||||||
TRACE("(%p)\n",This);
|
TRACE("(%p)->(ref before=%lu)\n",This, refCount + 1);
|
||||||
|
|
||||||
ref = InterlockedDecrement(&This->ref);
|
|
||||||
|
|
||||||
/* destroy the object if there's no more reference on it */
|
/* destroy the object if there's no more reference on it */
|
||||||
if (ref == 0) {
|
if (!refCount) {
|
||||||
HeapFree(GetProcessHeap(),0,This->URLName);
|
HeapFree(GetProcessHeap(),0,This->URLName);
|
||||||
HeapFree(GetProcessHeap(),0,This);
|
HeapFree(GetProcessHeap(),0,This);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ref;
|
URLMON_UnlockModule();
|
||||||
|
|
||||||
|
return refCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
|
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
|
||||||
|
|
||||||
|
LONG URLMON_refCount = 0;
|
||||||
|
|
||||||
HINSTANCE URLMON_hInstance = 0;
|
HINSTANCE URLMON_hInstance = 0;
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -76,9 +78,7 @@ HRESULT WINAPI URLMON_DllInstall(BOOL bInstall, LPCWSTR cmdline)
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI URLMON_DllCanUnloadNow(void)
|
HRESULT WINAPI URLMON_DllCanUnloadNow(void)
|
||||||
{
|
{
|
||||||
FIXME("(void): stub\n");
|
return URLMON_refCount != 0 ? S_FALSE : S_OK;
|
||||||
|
|
||||||
return S_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,6 +125,8 @@ CF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
|
||||||
static ULONG WINAPI CF_AddRef(LPCLASSFACTORY iface)
|
static ULONG WINAPI CF_AddRef(LPCLASSFACTORY iface)
|
||||||
{
|
{
|
||||||
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
||||||
|
URLMON_LockModule();
|
||||||
|
|
||||||
return InterlockedIncrement(&This->ref);
|
return InterlockedIncrement(&This->ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +139,8 @@ static ULONG WINAPI CF_Release(LPCLASSFACTORY iface)
|
||||||
if (ref == 0)
|
if (ref == 0)
|
||||||
HeapFree(GetProcessHeap(), 0, This);
|
HeapFree(GetProcessHeap(), 0, This);
|
||||||
|
|
||||||
|
URLMON_UnlockModule();
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,8 +164,13 @@ static HRESULT WINAPI CF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
|
||||||
|
|
||||||
static HRESULT WINAPI CF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
|
static HRESULT WINAPI CF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
|
||||||
{
|
{
|
||||||
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
|
TRACE("(%d)\n", dolock);
|
||||||
FIXME("(%p)->(%d),stub!\n",This,dolock);
|
|
||||||
|
if (dolock)
|
||||||
|
URLMON_LockModule();
|
||||||
|
else
|
||||||
|
URLMON_UnlockModule();
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,13 @@ extern HINSTANCE URLMON_hInstance;
|
||||||
extern HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
|
extern HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
|
||||||
extern HRESULT ZoneMgrImpl_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))
|
#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
|
||||||
|
|
||||||
#endif /* __WINE_URLMON_MAIN_H */
|
#endif /* __WINE_URLMON_MAIN_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue