From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 46 ++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 7f646e5fc31..2896677a231 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -2269,7 +2269,7 @@ static HRESULT WINAPI IDirectPlay4Impl_EnumPlayers( IDirectPlay4 *iface, GUID *i /* This function should call the registered callback function that the user passed into EnumSessions for each entry available. */ -static void DP_InvokeEnumSessionCallbacks +static BOOL DP_InvokeEnumSessionCallbacks ( LPDPENUMSESSIONSCALLBACK2 lpEnumSessionsCallback2, LPVOID lpNSInfo, DWORD dwTimeout, @@ -2285,13 +2285,11 @@ static void DP_InvokeEnumSessionCallbacks { TRACE( "EnumSessionsCallback2 invoked\n" ); if( !lpEnumSessionsCallback2( lpSessionDesc, &dwTimeout, 0, lpContext ) ) - { - return; - } + return FALSE; }
/* Invoke one last time to indicate that there is no more to come */ - lpEnumSessionsCallback2( NULL, &dwTimeout, DPESC_TIMEDOUT, lpContext ); + return lpEnumSessionsCallback2( NULL, &dwTimeout, DPESC_TIMEDOUT, lpContext ); }
static DWORD CALLBACK DP_EnumSessionsSendAsyncRequestThread( LPVOID lpContext ) @@ -2473,30 +2471,36 @@ static HRESULT WINAPI IDirectPlay4Impl_EnumSessions( IDirectPlay4 *iface, DPSESS return hr; }
- if ( !(flags & DPENUMSESSIONS_ASYNC) ) + for ( ;; ) { - EnterCriticalSection( &This->lock ); + if ( !(flags & DPENUMSESSIONS_ASYNC) ) + { + EnterCriticalSection( &This->lock );
- /* Invalidate the session cache for the interface */ - NS_InvalidateSessionCache( This->dp2->lpNameServerData ); + /* Invalidate the session cache for the interface */ + NS_InvalidateSessionCache( This->dp2->lpNameServerData );
- LeaveCriticalSection( &This->lock ); + LeaveCriticalSection( &This->lock );
- /* Send the broadcast for session enumeration */ - hr = NS_SendSessionRequestBroadcast( &sdesc->guidApplication, flags, &This->dp2->spData ); - if ( FAILED( hr ) ) - return hr; - SleepEx( timeout, FALSE ); - } + /* Send the broadcast for session enumeration */ + hr = NS_SendSessionRequestBroadcast( &sdesc->guidApplication, flags, + &This->dp2->spData ); + if ( FAILED( hr ) ) + return hr; + SleepEx( timeout, FALSE ); + }
- EnterCriticalSection( &This->lock ); + EnterCriticalSection( &This->lock );
- NS_PruneSessionCache( This->dp2->lpNameServerData ); - NS_ResetSessionEnumeration( This->dp2->lpNameServerData ); + NS_PruneSessionCache( This->dp2->lpNameServerData ); + NS_ResetSessionEnumeration( This->dp2->lpNameServerData );
- LeaveCriticalSection( &This->lock ); + LeaveCriticalSection( &This->lock );
- DP_InvokeEnumSessionCallbacks( enumsessioncb, This->dp2->lpNameServerData, timeout, context ); + if ( !DP_InvokeEnumSessionCallbacks( enumsessioncb, This->dp2->lpNameServerData, timeout, + context ) ) + break; + }
if ( flags & DPENUMSESSIONS_ASYNC ) {