dplayx: Implement proper interface locking for DP_EnumSession.

This commit is contained in:
Alessandro Pignotti 2007-03-30 15:00:06 +02:00 committed by Alexandre Julliard
parent afdf49f161
commit 3040e09ae3
2 changed files with 6 additions and 1 deletions

View file

@ -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

View file

@ -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 */