Commit 5c81f829 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

rpcrt4: Store server thread handle in RpcServerProtseq.

parent a8d956b5
......@@ -669,6 +669,11 @@ static DWORD CALLBACK RPCRT4_server_thread(LPVOID the_arg)
{
/* cleanup */
cps->ops->free_wait_array(cps, objs);
break;
}
else if (res == 0)
set_ready_event = TRUE;
}
EnterCriticalSection(&cps->cs);
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)
SetEvent(cps->server_ready_event);
break;
}
else if (res == 0)
set_ready_event = TRUE;
}
EnterCriticalSection(&listen_cs);
CloseHandle(cps->server_thread);
cps->server_thread = NULL;
LeaveCriticalSection(&listen_cs);
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)
{
RPC_STATUS status = RPC_S_OK;
HANDLE server_thread;
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->server_ready_event) ps->server_ready_event = CreateEventW(NULL, FALSE, FALSE, NULL);
server_thread = CreateThread(NULL, 0, RPCRT4_server_thread, ps, 0, NULL);
if (!server_thread)
{
ps->server_thread = CreateThread(NULL, 0, RPCRT4_server_thread, ps, 0, NULL);
if (!ps->server_thread)
status = RPC_S_OUT_OF_RESOURCES;
goto done;
}
ps->is_listening = TRUE;
CloseHandle(server_thread);
done:
LeaveCriticalSection(&listen_cs);
......
......@@ -37,8 +37,8 @@ typedef struct _RpcServerProtseq
struct list connections; /* CS cs */
CRITICAL_SECTION cs;
/* is the server currently listening? */
BOOL is_listening; /* CS ::listen_cs */
/* handle to listening thread */
HANDLE server_thread; /* CS ::listen_cs */
/* mutex for ensuring only one thread can change state at a time */
HANDLE mgr_mutex;
/* set when server thread has finished opening connections */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment