Jacek Caban : rpcrt4: Store server thread handle in RpcServerProtseq.
Alexandre Julliard
julliard at winehq.org
Wed May 31 16:20:18 CDT 2017
Module: wine
Branch: master
Commit: 5c81f8295e379bf09b51466eb387b6df9c9d70bb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5c81f8295e379bf09b51466eb387b6df9c9d70bb
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed May 31 17:30:10 2017 +0200
rpcrt4: Store server thread handle in RpcServerProtseq.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/rpcrt4/rpc_server.c | 37 ++++++++++++++++++-------------------
dlls/rpcrt4/rpc_server.h | 4 ++--
2 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c
index dcfac70..d8225f3 100644
--- a/dlls/rpcrt4/rpc_server.c
+++ b/dlls/rpcrt4/rpc_server.c
@@ -669,21 +669,26 @@ static DWORD CALLBACK RPCRT4_server_thread(LPVOID the_arg)
{
/* cleanup */
cps->ops->free_wait_array(cps, objs);
-
- EnterCriticalSection(&cps->cs);
- LIST_FOR_EACH_ENTRY(conn, &cps->listeners, RpcConnection, protseq_entry)
- RPCRT4_CloseConnection(conn);
- LIST_FOR_EACH_ENTRY(conn, &cps->connections, RpcConnection, protseq_entry)
- rpcrt4_conn_close_read(conn);
- LeaveCriticalSection(&cps->cs);
-
- if (res == 0 && !std_listen)
- SetEvent(cps->server_ready_event);
break;
}
else if (res == 0)
set_ready_event = TRUE;
}
+
+ EnterCriticalSection(&cps->cs);
+ LIST_FOR_EACH_ENTRY(conn, &cps->listeners, RpcConnection, protseq_entry)
+ RPCRT4_CloseConnection(conn);
+ LIST_FOR_EACH_ENTRY(conn, &cps->connections, RpcConnection, protseq_entry)
+ rpcrt4_conn_close_read(conn);
+ LeaveCriticalSection(&cps->cs);
+
+ if (res == 0 && !std_listen)
+ SetEvent(cps->server_ready_event);
+
+ 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);
diff --git a/dlls/rpcrt4/rpc_server.h b/dlls/rpcrt4/rpc_server.h
index 130dde7..5e04365 100644
--- a/dlls/rpcrt4/rpc_server.h
+++ b/dlls/rpcrt4/rpc_server.h
@@ -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 */
More information about the wine-cvs
mailing list