rpcrt4: Store server thread handle in RpcServerProtseq.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
a8d956b5b6
commit
5c81f8295e
|
@ -669,6 +669,11 @@ static DWORD CALLBACK RPCRT4_server_thread(LPVOID the_arg)
|
||||||
{
|
{
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
cps->ops->free_wait_array(cps, objs);
|
cps->ops->free_wait_array(cps, objs);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (res == 0)
|
||||||
|
set_ready_event = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
EnterCriticalSection(&cps->cs);
|
EnterCriticalSection(&cps->cs);
|
||||||
LIST_FOR_EACH_ENTRY(conn, &cps->listeners, RpcConnection, protseq_entry)
|
LIST_FOR_EACH_ENTRY(conn, &cps->listeners, RpcConnection, protseq_entry)
|
||||||
|
@ -679,11 +684,11 @@ static DWORD CALLBACK RPCRT4_server_thread(LPVOID the_arg)
|
||||||
|
|
||||||
if (res == 0 && !std_listen)
|
if (res == 0 && !std_listen)
|
||||||
SetEvent(cps->server_ready_event);
|
SetEvent(cps->server_ready_event);
|
||||||
break;
|
|
||||||
}
|
EnterCriticalSection(&listen_cs);
|
||||||
else if (res == 0)
|
CloseHandle(cps->server_thread);
|
||||||
set_ready_event = TRUE;
|
cps->server_thread = NULL;
|
||||||
}
|
LeaveCriticalSection(&listen_cs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -707,21 +712,15 @@ static void RPCRT4_sync_with_server_thread(RpcServerProtseq *ps)
|
||||||
static RPC_STATUS RPCRT4_start_listen_protseq(RpcServerProtseq *ps, BOOL auto_listen)
|
static RPC_STATUS RPCRT4_start_listen_protseq(RpcServerProtseq *ps, BOOL auto_listen)
|
||||||
{
|
{
|
||||||
RPC_STATUS status = RPC_S_OK;
|
RPC_STATUS status = RPC_S_OK;
|
||||||
HANDLE server_thread;
|
|
||||||
|
|
||||||
EnterCriticalSection(&listen_cs);
|
EnterCriticalSection(&listen_cs);
|
||||||
if (ps->is_listening) goto done;
|
if (ps->server_thread) goto done;
|
||||||
|
|
||||||
if (!ps->mgr_mutex) ps->mgr_mutex = CreateMutexW(NULL, FALSE, NULL);
|
if (!ps->mgr_mutex) ps->mgr_mutex = CreateMutexW(NULL, FALSE, NULL);
|
||||||
if (!ps->server_ready_event) ps->server_ready_event = CreateEventW(NULL, FALSE, FALSE, NULL);
|
if (!ps->server_ready_event) ps->server_ready_event = CreateEventW(NULL, FALSE, FALSE, NULL);
|
||||||
server_thread = CreateThread(NULL, 0, RPCRT4_server_thread, ps, 0, NULL);
|
ps->server_thread = CreateThread(NULL, 0, RPCRT4_server_thread, ps, 0, NULL);
|
||||||
if (!server_thread)
|
if (!ps->server_thread)
|
||||||
{
|
|
||||||
status = RPC_S_OUT_OF_RESOURCES;
|
status = RPC_S_OUT_OF_RESOURCES;
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
ps->is_listening = TRUE;
|
|
||||||
CloseHandle(server_thread);
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
LeaveCriticalSection(&listen_cs);
|
LeaveCriticalSection(&listen_cs);
|
||||||
|
|
|
@ -37,8 +37,8 @@ typedef struct _RpcServerProtseq
|
||||||
struct list connections; /* CS cs */
|
struct list connections; /* CS cs */
|
||||||
CRITICAL_SECTION cs;
|
CRITICAL_SECTION cs;
|
||||||
|
|
||||||
/* is the server currently listening? */
|
/* handle to listening thread */
|
||||||
BOOL is_listening; /* CS ::listen_cs */
|
HANDLE server_thread; /* CS ::listen_cs */
|
||||||
/* mutex for ensuring only one thread can change state at a time */
|
/* mutex for ensuring only one thread can change state at a time */
|
||||||
HANDLE mgr_mutex;
|
HANDLE mgr_mutex;
|
||||||
/* set when server thread has finished opening connections */
|
/* set when server thread has finished opening connections */
|
||||||
|
|
Loading…
Reference in New Issue