Robert Shearman : rpcrt4: Make the reference counting in the standard proxy thread-safe.
Module: wine Branch: master Commit: ada61620de93a6e75ac499224ddbb23e20c88333 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=ada61620de93a6e75ac49922... Author: Robert Shearman <rob(a)codeweavers.com> Date: Tue Aug 29 21:16:44 2006 +0100 rpcrt4: Make the reference counting in the standard proxy thread-safe. --- dlls/rpcrt4/cproxy.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dlls/rpcrt4/cproxy.c b/dlls/rpcrt4/cproxy.c index 70f0556..280dbe1 100644 --- a/dlls/rpcrt4/cproxy.c +++ b/dlls/rpcrt4/cproxy.c @@ -44,7 +44,7 @@ struct StublessThunk; typedef struct { const IRpcProxyBufferVtbl *lpVtbl; LPVOID *PVtbl; - DWORD RefCount; + LONG RefCount; const MIDL_STUBLESS_PROXY_INFO *stubless; const IID* piid; LPUNKNOWN pUnkOuter; @@ -222,13 +222,13 @@ static HRESULT WINAPI StdProxy_QueryInte if (IsEqualGUID(&IID_IUnknown,riid) || IsEqualGUID(This->piid,riid)) { *obj = &This->PVtbl; - This->RefCount++; + InterlockedIncrement(&This->RefCount); return S_OK; } if (IsEqualGUID(&IID_IRpcProxyBuffer,riid)) { *obj = &This->lpVtbl; - This->RefCount++; + InterlockedIncrement(&This->RefCount); return S_OK; } @@ -240,19 +240,19 @@ static ULONG WINAPI StdProxy_AddRef(LPRP ICOM_THIS_MULTI(StdProxyImpl,lpVtbl,iface); TRACE("(%p)->AddRef()\n",This); - return ++(This->RefCount); + return InterlockedIncrement(&This->RefCount); } static ULONG WINAPI StdProxy_Release(LPRPCPROXYBUFFER iface) { + ULONG refs; ICOM_THIS_MULTI(StdProxyImpl,lpVtbl,iface); TRACE("(%p)->Release()\n",This); - if (!--(This->RefCount)) { + refs = InterlockedDecrement(&This->RefCount); + if (!refs) StdProxy_Destruct((LPRPCPROXYBUFFER)&This->lpVtbl); - return 0; - } - return This->RefCount; + return refs; } static HRESULT WINAPI StdProxy_Connect(LPRPCPROXYBUFFER iface,
participants (1)
-
Alexandre Julliard