dpnet: Share message handler between IDirectPlay8ThreadPool objects.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alistair Leslie-Hughes 2017-03-23 01:57:05 +00:00 committed by Alexandre Julliard
parent 7584e082bf
commit 072c58e322
3 changed files with 16 additions and 13 deletions

View file

@ -122,10 +122,6 @@ struct IDirectPlay8ThreadPoolImpl
{
IDirectPlay8ThreadPool IDirectPlay8ThreadPool_iface;
LONG ref;
PFNDPNMESSAGEHANDLER msghandler;
DWORD flags;
void *usercontext;
};
/**

View file

@ -70,7 +70,7 @@ static void create_threadpool(void)
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDirectPlay8ThreadPool_Initialize(pool2, NULL, &DirectPlayThreadHandler, 0);
todo_wine ok(hr == DPNERR_ALREADYINITIALIZED, "got 0x%08x\n", hr);
ok(hr == DPNERR_ALREADYINITIALIZED, "got 0x%08x\n", hr);
hr = IDirectPlay8ThreadPool_GetThreadCount(pool1, -1, &threadcnt, 0);
ok(hr == S_OK, "got 0x%08x\n", hr);
@ -103,7 +103,7 @@ static void create_threadpool(void)
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDirectPlay8ThreadPool_Close(pool2, 0);
todo_wine ok(hr == DPNERR_UNINITIALIZED, "got 0x%08x\n", hr);
ok(hr == DPNERR_UNINITIALIZED, "got 0x%08x\n", hr);
IDirectPlay8ThreadPool_Release(pool1);
IDirectPlay8ThreadPool_Release(pool2);
@ -226,13 +226,13 @@ static void test_singleton(void)
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDirectPlay8ThreadPool_Initialize(pool2, NULL, &DirectPlayThreadHandler, 0);
todo_wine ok(hr == DPNERR_ALREADYINITIALIZED, "got 0x%08x\n", hr);
ok(hr == DPNERR_ALREADYINITIALIZED, "got 0x%08x\n", hr);
hr = IDirectPlay8ThreadPool_Close(pool1, 0);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDirectPlay8ThreadPool_Close(pool2, 0);
todo_wine ok(hr == DPNERR_UNINITIALIZED, "got 0x%08x\n", hr);
ok(hr == DPNERR_UNINITIALIZED, "got 0x%08x\n", hr);
IDirectPlay8ThreadPool_Release(pool1);
IDirectPlay8ThreadPool_Release(pool2);

View file

@ -36,6 +36,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
static PFNDPNMESSAGEHANDLER threadpool_msghandler = NULL;
static DWORD threadpool_flags = 0;
static void *threadpool_usercontext = NULL;
static inline IDirectPlay8ThreadPoolImpl *impl_from_IDirectPlay8ThreadPool(IDirectPlay8ThreadPool *iface)
{
return CONTAINING_RECORD(iface, IDirectPlay8ThreadPoolImpl, IDirectPlay8ThreadPool_iface);
@ -89,12 +93,12 @@ static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Initialize(IDirectPlay8ThreadPo
if(!pfn)
return DPNERR_INVALIDPARAM;
if(This->msghandler)
if(threadpool_msghandler)
return DPNERR_ALREADYINITIALIZED;
This->msghandler = pfn;
This->flags = dwFlags;
This->usercontext = pvUserContext;
threadpool_msghandler = pfn;
threadpool_flags = dwFlags;
threadpool_usercontext = pvUserContext;
return DPN_OK;
}
@ -106,7 +110,10 @@ static HRESULT WINAPI IDirectPlay8ThreadPoolImpl_Close(IDirectPlay8ThreadPool *i
FIXME("(%p)->(%x)\n", This, dwFlags);
This->msghandler = NULL;
if(!threadpool_msghandler)
return DPNERR_UNINITIALIZED;
threadpool_msghandler = NULL;
return DPN_OK;
}