rpcrt4: Implement waiting in RpcMgmtWaitServerListen.

This commit is contained in:
Alexandre Julliard 2010-11-09 23:11:35 +01:00
parent d5fa2ceaca
commit 749f22948c

View File

@ -104,6 +104,8 @@ static BOOL std_listen;
static LONG manual_listen_count;
/* total listeners including auto listeners */
static LONG listen_count;
/* event set once all listening is finished */
static HANDLE listen_done_event;
static UUID uuid_nil;
@ -772,6 +774,10 @@ static void RPCRT4_stop_listen(BOOL auto_listen)
LIST_FOR_EACH_ENTRY(cps, &protseqs, RpcServerProtseq, entry)
RPCRT4_sync_with_server_thread(cps);
EnterCriticalSection(&listen_cs);
if (listen_done_event) SetEvent( listen_done_event );
listen_done_event = 0;
LeaveCriticalSection(&listen_cs);
return;
}
assert(listen_count >= 0);
@ -1469,6 +1475,8 @@ RPC_STATUS WINAPI RpcServerListen( UINT MinimumCallThreads, UINT MaxCalls, UINT
*/
RPC_STATUS WINAPI RpcMgmtWaitServerListen( void )
{
HANDLE event;
TRACE("()\n");
EnterCriticalSection(&listen_cs);
@ -1477,11 +1485,20 @@ RPC_STATUS WINAPI RpcMgmtWaitServerListen( void )
LeaveCriticalSection(&listen_cs);
return RPC_S_NOT_LISTENING;
}
if (listen_done_event) {
LeaveCriticalSection(&listen_cs);
return RPC_S_ALREADY_LISTENING;
}
event = CreateEventW( NULL, TRUE, FALSE, NULL );
listen_done_event = event;
LeaveCriticalSection(&listen_cs);
FIXME("not waiting for server calls to finish\n");
TRACE( "waiting for server calls to finish\n" );
WaitForSingleObject( event, INFINITE );
TRACE( "done waiting\n" );
CloseHandle( event );
return RPC_S_OK;
}