From f0189b8789280f2255bb2c2bf32e1ce018477c6b Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Fri, 9 Mar 2007 18:55:13 +0000 Subject: [PATCH] ole32: Implement CoAddRefServerProcess and CoReleaseServerProcess. --- dlls/ole32/compobj.c | 41 +++++++++++++++++++++++++++++++++++++---- dlls/ole32/tests/marshal.c | 2 +- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index d0ef89ca329..a5a322060b9 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -106,6 +106,8 @@ struct registered_psclsid * libraries are freed */ static LONG s_COMLockCount = 0; +/* Reference count used by CoAddRefServerProcess/CoReleaseServerProcess */ +static LONG s_COMServerProcessReferences = 0; /* * This linked list contains the list of registered class objects. These @@ -2771,11 +2773,23 @@ HRESULT WINAPI CoSuspendClassObjects(void) * * RETURNS * New reference count. + * + * SEE ALSO + * CoReleaseServerProcess(). */ ULONG WINAPI CoAddRefServerProcess(void) { - FIXME("\n"); - return 2; + ULONG refs; + + TRACE("\n"); + + EnterCriticalSection(&csRegisteredClassList); + refs = ++s_COMServerProcessReferences; + LeaveCriticalSection(&csRegisteredClassList); + + TRACE("refs before: %d\n", refs - 1); + + return refs; } /*********************************************************************** @@ -2786,11 +2800,30 @@ ULONG WINAPI CoAddRefServerProcess(void) * * RETURNS * New reference count. + * + * NOTES + * When reference count reaches 0, this function suspends all registered + * classes so no new connections are accepted. + * + * SEE ALSO + * CoAddRefServerProcess(), CoSuspendClassObjects(). */ ULONG WINAPI CoReleaseServerProcess(void) { - FIXME("\n"); - return 1; + ULONG refs; + + TRACE("\n"); + + EnterCriticalSection(&csRegisteredClassList); + + refs = --s_COMServerProcessReferences; + /* FIXME: if (!refs) COM_SuspendClassObjects(); */ + + LeaveCriticalSection(&csRegisteredClassList); + + TRACE("refs after: %d\n", refs); + + return refs; } /*********************************************************************** diff --git a/dlls/ole32/tests/marshal.c b/dlls/ole32/tests/marshal.c index 12ab39bc7a0..0c0dff7ebb4 100644 --- a/dlls/ole32/tests/marshal.c +++ b/dlls/ole32/tests/marshal.c @@ -2303,7 +2303,7 @@ static void test_local_server(void) /* wait for shutdown signal */ ret = WaitForSingleObject(heventShutdown, 0); - todo_wine { ok(ret != WAIT_TIMEOUT, "Server didn't shut down\n"); } + ok(ret != WAIT_TIMEOUT, "Server didn't shut down\n"); /* try to connect again after SCM has suspended registered class objects */ hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, NULL, -- 2.11.4.GIT