ole32: Test remaining class, object and server reference counts at server exit.

Dmitry Timoshkov dmitry at baikal.ru
Mon Jun 10 22:42:49 CDT 2013


---
 dlls/ole32/tests/ole_server.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/dlls/ole32/tests/ole_server.c b/dlls/ole32/tests/ole_server.c
index 9cff693..9c901ee 100644
--- a/dlls/ole32/tests/ole_server.c
+++ b/dlls/ole32/tests/ole_server.c
@@ -61,6 +61,8 @@ static const struct
 #undef GUID_NAME
 };
 
+static LONG obj_ref, class_ref, server_locks;
+
 static const char *debugstr_guid(const GUID *guid)
 {
     static char buf[50];
@@ -118,6 +120,8 @@ static ULONG WINAPI UnknownImpl_AddRef(IUnknown *iface)
     UnknownImpl *This = impl_from_IUnknown(iface);
     ULONG ref = InterlockedIncrement(&This->ref);
 
+    InterlockedIncrement(&obj_ref);
+
     trace("server: unknown_AddRef: %p, ref %u\n", iface, ref);
     return ref;
 }
@@ -127,6 +131,8 @@ static ULONG WINAPI UnknownImpl_Release(IUnknown *iface)
     UnknownImpl *This = impl_from_IUnknown(iface);
     ULONG ref = InterlockedDecrement(&This->ref);
 
+    InterlockedDecrement(&obj_ref);
+
     trace("server: unknown_Release: %p, ref %u\n", iface, ref);
     if (ref == 0) HeapFree(GetProcessHeap(), 0, This);
     return ref;
@@ -176,6 +182,8 @@ static ULONG WINAPI ClassFactoryImpl_AddRef(IClassFactory *iface)
     ClassFactoryImpl *This = impl_from_IClassFactory(iface);
     ULONG ref = InterlockedIncrement(&This->ref);
 
+    InterlockedIncrement(&class_ref);
+
     trace("server: factory_AddRef: %p, ref %u\n", iface, ref);
     return ref;
 }
@@ -185,6 +193,8 @@ static ULONG WINAPI ClassFactoryImpl_Release(IClassFactory *iface)
     ClassFactoryImpl *This = impl_from_IClassFactory(iface);
     ULONG ref = InterlockedDecrement(&This->ref);
 
+    InterlockedDecrement(&class_ref);
+
     trace("server: factory_Release: %p, ref %u\n", iface, ref);
     return ref;
 }
@@ -203,7 +213,8 @@ static HRESULT WINAPI ClassFactoryImpl_CreateInstance(IClassFactory *iface,
     if (!unknown) return E_OUTOFMEMORY;
 
     unknown->IUnknown_iface.lpVtbl = &UnknownImpl_Vtbl;
-    unknown->ref = 1;
+    unknown->ref = 0;
+    IUnknown_AddRef(&unknown->IUnknown_iface);
 
     hr = IUnknown_QueryInterface(&unknown->IUnknown_iface, iid, ppv);
     IUnknown_Release(&unknown->IUnknown_iface);
@@ -213,7 +224,6 @@ static HRESULT WINAPI ClassFactoryImpl_CreateInstance(IClassFactory *iface,
 
 static HRESULT WINAPI ClassFactoryImpl_LockServer(IClassFactory *iface, BOOL lock)
 {
-    static LONG server_locks;
     ULONG ref = lock ? InterlockedIncrement(&server_locks) : InterlockedDecrement(&server_locks);
 
     trace("server: factory_LockServer: %p,%d, ref %u\n", iface, lock, ref);
@@ -258,6 +268,11 @@ static void ole_server(void)
             trace("server: waiting for requests\n");
             WaitForSingleObject(done_event, INFINITE);
 
+            /* 1 remainining class ref is supposed to be cleared by CoRevokeClassObject */
+            ok(class_ref == 1, "expected 1 class refs, got %d\n", class_ref);
+            ok(!obj_ref, "expected 0 object refs, got %d\n", obj_ref);
+            ok(!server_locks, "expected 0 server locks, got %d\n", server_locks);
+
             CloseHandle(done_event);
             CloseHandle(init_done_event);
             if (0)
-- 
1.8.3




More information about the wine-patches mailing list