From 3040e09ae324c71c5ec9adcd8b24724288f99d7f Mon Sep 17 00:00:00 2001 From: Alessandro Pignotti Date: Fri, 30 Mar 2007 15:00:06 +0200 Subject: [PATCH] dplayx: Implement proper interface locking for DP_EnumSession. --- dlls/dplayx/dplay.c | 6 +++++- dlls/dplayx/dplay_global.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index d446f51897..650adfd9bf 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -272,6 +272,7 @@ static BOOL DP_CreateDirectPlay2( LPVOID lpDP ) This->dp2->bConnectionOpen = FALSE; This->dp2->hEnumSessionThread = INVALID_HANDLE_VALUE; + This->dp2->dwEnumSessionLock = 0; This->dp2->bHostInterface = FALSE; @@ -2273,7 +2274,6 @@ static HRESULT WINAPI DP_IF_EnumSessions return hr; } - /* FIXME: Interface locking sucks in this method */ if( ( dwFlags & DPENUMSESSIONS_ASYNC ) ) { /* Enumerate everything presently in the local session cache */ @@ -2281,11 +2281,14 @@ static HRESULT WINAPI DP_IF_EnumSessions This->dp2->lpNameServerData, dwTimeout, lpContext ); + if( This->dp2->dwEnumSessionLock != 0 ) + return DPERR_CONNECTING; /* See if we've already created a thread to service this interface */ if( This->dp2->hEnumSessionThread == INVALID_HANDLE_VALUE ) { DWORD dwThreadId; + This->dp2->dwEnumSessionLock++; /* Send the first enum request inline since the user may cancel a dialog * if one is presented. Also, may also have a connecting return code. @@ -2326,6 +2329,7 @@ static HRESULT WINAPI DP_IF_EnumSessions 0, &dwThreadId ); } + This->dp2->dwEnumSessionLock--; } } else diff --git a/dlls/dplayx/dplay_global.h b/dlls/dplayx/dplay_global.h index 0c02486762..095374d28b 100644 --- a/dlls/dplayx/dplay_global.h +++ b/dlls/dplayx/dplay_global.h @@ -164,6 +164,7 @@ typedef struct tagDirectPlay2Data /* For async EnumSessions requests */ HANDLE hEnumSessionThread; HANDLE hKillEnumSessionThreadEvent; + DWORD dwEnumSessionLock; LPVOID lpNameServerData; /* DPlay interface doesn't know contents */