Huw Davies : rpcrt4:
Tests on NdrCStdStubBuffer_Release to show that we shouldn'
t call Disconnect.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Sep 7 03:45:51 CDT 2006
Module: wine
Branch: master
Commit: 9b91307677494e1f7d58a0b485eb058938c8151c
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=9b91307677494e1f7d58a0b485eb058938c8151c
Author: Huw Davies <huw at codeweavers.com>
Date: Wed Aug 30 17:20:17 2006 +0100
rpcrt4: Tests on NdrCStdStubBuffer_Release to show that we shouldn't call Disconnect.
Also call IPSFactoryBuffer_Release on the 2nd arg, rather than on This->pPSFactory.
---
dlls/rpcrt4/cstub.c | 6 ++++--
dlls/rpcrt4/tests/cstub.c | 46 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/dlls/rpcrt4/cstub.c b/dlls/rpcrt4/cstub.c
index 2deb2b1..b33363b 100644
--- a/dlls/rpcrt4/cstub.c
+++ b/dlls/rpcrt4/cstub.c
@@ -121,9 +121,11 @@ ULONG WINAPI NdrCStdStubBuffer_Release(L
refs = InterlockedDecrement(&This->RefCount);
if (!refs)
{
+ /* test_Release shows that native doesn't call Disconnect here.
+ We'll leave it in for the time being. */
IRpcStubBuffer_Disconnect(iface);
- if(This->pPSFactory)
- IPSFactoryBuffer_Release(This->pPSFactory);
+
+ IPSFactoryBuffer_Release(pPSF);
HeapFree(GetProcessHeap(),0,This);
}
return refs;
diff --git a/dlls/rpcrt4/tests/cstub.c b/dlls/rpcrt4/tests/cstub.c
index 733acc4..7039943 100644
--- a/dlls/rpcrt4/tests/cstub.c
+++ b/dlls/rpcrt4/tests/cstub.c
@@ -765,6 +765,51 @@ static void test_Disconnect(IPSFactoryBu
ok(cstd_stub->pvServerObject == NULL, "pvServerObject %p\n", cstd_stub->pvServerObject);
}
+
+static int release_test_psfacbuf_release_called;
+static ULONG WINAPI release_test_pretend_psfacbuf_release(IUnknown *pUnk)
+{
+ release_test_psfacbuf_release_called++;
+ return 1;
+}
+
+static IUnknownVtbl release_test_pretend_psfacbuf_vtbl =
+{
+ NULL,
+ NULL,
+ release_test_pretend_psfacbuf_release
+};
+
+static void test_Release(IPSFactoryBuffer *ppsf)
+{
+ LONG facbuf_refs;
+ IUnknownVtbl *orig_vtbl = &connect_test_orig_vtbl;
+ IUnknown *obj = (IUnknown*)&orig_vtbl;
+ IUnknownVtbl *pretend_psfacbuf_vtbl = &release_test_pretend_psfacbuf_vtbl;
+ IUnknown *pretend_psfacbuf = (IUnknown *)&pretend_psfacbuf_vtbl;
+ IRpcStubBuffer *pstub = create_stub(ppsf, &IID_if1, obj, S_OK);
+ CStdStubBuffer *cstd_stub = (CStdStubBuffer*)pstub;
+
+ facbuf_refs = PSFactoryBuffer.RefCount;
+
+ /* This shows that NdrCStdStubBuffer_Release doesn't call Disconnect */
+ ok(cstd_stub->RefCount == 1, "ref count %ld\n", cstd_stub->RefCount);
+ connect_test_orig_release_called = 0;
+ IRpcStubBuffer_Release(pstub);
+todo_wine {
+ ok(connect_test_orig_release_called == 0, "release called %d\n", connect_test_orig_release_called);
+}
+ ok(PSFactoryBuffer.RefCount == facbuf_refs - 1, "factory buffer refs %ld orig %ld\n", PSFactoryBuffer.RefCount, facbuf_refs);
+
+ /* This shows that NdrCStdStubBuffer_Release calls Release on its 2nd arg, rather than on This->pPSFactory
+ (which are usually the same and indeed it's odd that _Release requires this 2nd arg). */
+ pstub = create_stub(ppsf, &IID_if1, obj, S_OK);
+ ok(PSFactoryBuffer.RefCount == facbuf_refs, "factory buffer refs %ld orig %ld\n", PSFactoryBuffer.RefCount, facbuf_refs);
+ NdrCStdStubBuffer_Release(pstub, (IPSFactoryBuffer*)pretend_psfacbuf);
+ ok(release_test_psfacbuf_release_called == 1, "pretend_psfacbuf_release called %d\n", release_test_psfacbuf_release_called);
+ ok(PSFactoryBuffer.RefCount == facbuf_refs, "factory buffer refs %ld orig %ld\n", PSFactoryBuffer.RefCount, facbuf_refs);
+}
+
START_TEST( cstub )
{
IPSFactoryBuffer *ppsf;
@@ -776,6 +821,7 @@ START_TEST( cstub )
test_CreateStub(ppsf);
test_Connect(ppsf);
test_Disconnect(ppsf);
+ test_Release(ppsf);
OleUninitialize();
}
More information about the wine-cvs
mailing list