mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-29 04:13:32 +00:00
[RPCRT4] Sync with Wine Staging 2.9. CORE-13362
6b53b79 rpcrt4: Use HEAP_ZERO_MEMORY to alloc RpcServerProtseq objects. 28f865b rpcrt4: Add close_read implementation for TCP connections. 29f0b28 rpcrt4: Add close_read implementation for named pipe connections. 42ba4d7 rpcrt4: Introduce op for closing connection read end and use it when shutting down server. ef267f1 rpcrt4: Store all active connections in RpcServerProtseq. dae3065 rpcrt4: Remove connection from list in RPCRT4_ReleaseConnection. 812897c rpcrt4: Use HEAP_ZERO_MEMORY to alloc RpcConnection objects. 13d529a rpcrt4: Renamed connections list to listeners. c953763 rpcrt4: Remove no longer needed helpers. b548338 rpcrt4: Implement cancel_call for named pipes. 372c9e0 rpcrt4: Cache event handle in RpcConnection_np object. 6e7a297 rpcrt4: Use non-blocking listening on named pipes. 4f4ac8c rpcrt4: Use named pipe in overlapped mode. bd6f807 rpcrt4: Simplify rpcrt4_conn_np_read implementation. f62b9d6 rpcrt4: Simplify rpcrt4_conn_np_write implementation. 2035294 rpcrt4: Use standard Wine list to store connections in RpcServerProtseq. e621593 rpcrt4: Always use winsock for networking. d0ed6d1 rpcrt4: Get rid of manual_listen_count and use binary state instead. svn path=/trunk/; revision=74904
This commit is contained in:
@@ -86,7 +86,8 @@ typedef struct _RpcConnection
|
||||
/* The active interface bound to server. */
|
||||
RPC_SYNTAX_IDENTIFIER ActiveInterface;
|
||||
USHORT NextCallId;
|
||||
struct _RpcConnection* Next;
|
||||
struct list protseq_entry;
|
||||
struct _RpcServerProtseq *protseq;
|
||||
struct _RpcBinding *server_binding;
|
||||
} RpcConnection;
|
||||
|
||||
@@ -99,6 +100,7 @@ struct connection_ops {
|
||||
int (*read)(RpcConnection *conn, void *buffer, unsigned int len);
|
||||
int (*write)(RpcConnection *conn, const void *buffer, unsigned int len);
|
||||
int (*close)(RpcConnection *conn);
|
||||
void (*close_read)(RpcConnection *conn);
|
||||
void (*cancel_call)(RpcConnection *conn);
|
||||
RPC_STATUS (*is_server_listening)(const char *endpoint);
|
||||
int (*wait_for_incoming_data)(RpcConnection *conn);
|
||||
@@ -192,6 +194,11 @@ static inline int rpcrt4_conn_close(RpcConnection *Connection)
|
||||
return Connection->ops->close(Connection);
|
||||
}
|
||||
|
||||
static inline void rpcrt4_conn_close_read(RpcConnection *connection)
|
||||
{
|
||||
connection->ops->close_read(connection);
|
||||
}
|
||||
|
||||
static inline void rpcrt4_conn_cancel_call(RpcConnection *Connection)
|
||||
{
|
||||
Connection->ops->cancel_call(Connection);
|
||||
|
||||
@@ -79,11 +79,9 @@ static CRITICAL_SECTION server_auth_info_cs = { &server_auth_info_cs_debug, -1,
|
||||
|
||||
/* whether the server is currently listening */
|
||||
static BOOL std_listen;
|
||||
/* number of manual listeners (calls to RpcServerListen) */
|
||||
static LONG manual_listen_count;
|
||||
/* total listeners including auto listeners */
|
||||
static LONG listen_count;
|
||||
/* event set once all listening is finished */
|
||||
/* event set once all manual listening is finished */
|
||||
static HANDLE listen_done_event;
|
||||
|
||||
static UUID uuid_nil;
|
||||
@@ -649,9 +647,12 @@ static DWORD CALLBACK RPCRT4_server_thread(LPVOID the_arg)
|
||||
{
|
||||
/* cleanup */
|
||||
cps->ops->free_wait_array(cps, objs);
|
||||
|
||||
EnterCriticalSection(&cps->cs);
|
||||
for (conn = cps->conn; conn; conn = conn->Next)
|
||||
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)
|
||||
@@ -713,13 +714,16 @@ static RPC_STATUS RPCRT4_start_listen(BOOL auto_listen)
|
||||
TRACE("\n");
|
||||
|
||||
EnterCriticalSection(&listen_cs);
|
||||
if (auto_listen || (manual_listen_count++ == 0))
|
||||
if (auto_listen || !listen_done_event)
|
||||
{
|
||||
status = RPC_S_OK;
|
||||
if(!auto_listen)
|
||||
listen_done_event = CreateEventW(NULL, TRUE, FALSE, NULL);
|
||||
if (++listen_count == 1)
|
||||
std_listen = TRUE;
|
||||
}
|
||||
LeaveCriticalSection(&listen_cs);
|
||||
if (status) return status;
|
||||
|
||||
if (std_listen)
|
||||
{
|
||||
@@ -742,51 +746,53 @@ static RPC_STATUS RPCRT4_start_listen(BOOL auto_listen)
|
||||
|
||||
static RPC_STATUS RPCRT4_stop_listen(BOOL auto_listen)
|
||||
{
|
||||
BOOL stop_listen = FALSE;
|
||||
RPC_STATUS status = RPC_S_OK;
|
||||
|
||||
EnterCriticalSection(&listen_cs);
|
||||
|
||||
if (!std_listen)
|
||||
if (!std_listen && (auto_listen || !listen_done_event))
|
||||
{
|
||||
status = RPC_S_NOT_LISTENING;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (auto_listen || (--manual_listen_count == 0))
|
||||
else
|
||||
{
|
||||
if (listen_count != 0 && --listen_count == 0) {
|
||||
RpcServerProtseq *cps;
|
||||
|
||||
std_listen = FALSE;
|
||||
LeaveCriticalSection(&listen_cs);
|
||||
|
||||
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;
|
||||
goto done;
|
||||
}
|
||||
stop_listen = listen_count != 0 && --listen_count == 0;
|
||||
assert(listen_count >= 0);
|
||||
if (stop_listen)
|
||||
std_listen = FALSE;
|
||||
}
|
||||
LeaveCriticalSection(&listen_cs);
|
||||
|
||||
if (status) return status;
|
||||
|
||||
if (stop_listen) {
|
||||
RpcServerProtseq *cps;
|
||||
LIST_FOR_EACH_ENTRY(cps, &protseqs, RpcServerProtseq, entry)
|
||||
RPCRT4_sync_with_server_thread(cps);
|
||||
}
|
||||
|
||||
done:
|
||||
LeaveCriticalSection(&listen_cs);
|
||||
return status;
|
||||
if (!auto_listen)
|
||||
{
|
||||
EnterCriticalSection(&listen_cs);
|
||||
SetEvent( listen_done_event );
|
||||
LeaveCriticalSection(&listen_cs);
|
||||
}
|
||||
return RPC_S_OK;
|
||||
}
|
||||
|
||||
static BOOL RPCRT4_protseq_is_endpoint_registered(RpcServerProtseq *protseq, const char *endpoint)
|
||||
{
|
||||
RpcConnection *conn;
|
||||
BOOL registered = FALSE;
|
||||
EnterCriticalSection(&protseq->cs);
|
||||
for (conn = protseq->conn; conn; conn = conn->Next)
|
||||
{
|
||||
if (!endpoint || !strcmp(endpoint, conn->Endpoint))
|
||||
LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection, protseq_entry) {
|
||||
if (!endpoint || !strcmp(endpoint, conn->Endpoint)) {
|
||||
registered = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
LeaveCriticalSection(&protseq->cs);
|
||||
return (conn != NULL);
|
||||
return registered;
|
||||
}
|
||||
|
||||
static RPC_STATUS RPCRT4_use_protseq(RpcServerProtseq* ps, const char *endpoint)
|
||||
@@ -835,7 +841,7 @@ RPC_STATUS WINAPI RpcServerInqBindings( RPC_BINDING_VECTOR** BindingVector )
|
||||
count = 0;
|
||||
LIST_FOR_EACH_ENTRY(ps, &protseqs, RpcServerProtseq, entry) {
|
||||
EnterCriticalSection(&ps->cs);
|
||||
for (conn = ps->conn; conn; conn = conn->Next)
|
||||
LIST_FOR_EACH_ENTRY(conn, &ps->listeners, RpcConnection, protseq_entry)
|
||||
count++;
|
||||
LeaveCriticalSection(&ps->cs);
|
||||
}
|
||||
@@ -848,7 +854,7 @@ RPC_STATUS WINAPI RpcServerInqBindings( RPC_BINDING_VECTOR** BindingVector )
|
||||
count = 0;
|
||||
LIST_FOR_EACH_ENTRY(ps, &protseqs, RpcServerProtseq, entry) {
|
||||
EnterCriticalSection(&ps->cs);
|
||||
for (conn = ps->conn; conn; conn = conn->Next) {
|
||||
LIST_FOR_EACH_ENTRY(conn, &ps->listeners, RpcConnection, protseq_entry) {
|
||||
RPCRT4_MakeBinding((RpcBinding**)&(*BindingVector)->BindingH[count],
|
||||
conn);
|
||||
count++;
|
||||
@@ -919,13 +925,10 @@ static RPC_STATUS alloc_serverprotoseq(UINT MaxCalls, const char *Protseq, RpcSe
|
||||
(*ps)->MaxCalls = MaxCalls;
|
||||
(*ps)->Protseq = RPCRT4_strdupA(Protseq);
|
||||
(*ps)->ops = ops;
|
||||
(*ps)->MaxCalls = 0;
|
||||
(*ps)->conn = NULL;
|
||||
list_init(&(*ps)->listeners);
|
||||
list_init(&(*ps)->connections);
|
||||
InitializeCriticalSection(&(*ps)->cs);
|
||||
(*ps)->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcServerProtseq.cs");
|
||||
(*ps)->is_listening = FALSE;
|
||||
(*ps)->mgr_mutex = NULL;
|
||||
(*ps)->server_ready_event = NULL;
|
||||
|
||||
list_add_head(&protseqs, &(*ps)->entry);
|
||||
|
||||
@@ -1505,25 +1508,23 @@ RPC_STATUS WINAPI RpcMgmtWaitServerListen( void )
|
||||
TRACE("()\n");
|
||||
|
||||
EnterCriticalSection(&listen_cs);
|
||||
|
||||
if (!std_listen) {
|
||||
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;
|
||||
|
||||
event = listen_done_event;
|
||||
LeaveCriticalSection(&listen_cs);
|
||||
|
||||
if (!event)
|
||||
return RPC_S_NOT_LISTENING;
|
||||
|
||||
TRACE( "waiting for server calls to finish\n" );
|
||||
WaitForSingleObject( event, INFINITE );
|
||||
TRACE( "done waiting\n" );
|
||||
|
||||
CloseHandle( event );
|
||||
EnterCriticalSection(&listen_cs);
|
||||
if (listen_done_event == event)
|
||||
{
|
||||
listen_done_event = NULL;
|
||||
CloseHandle( event );
|
||||
}
|
||||
LeaveCriticalSection(&listen_cs);
|
||||
return RPC_S_OK;
|
||||
}
|
||||
|
||||
@@ -1649,7 +1650,7 @@ RPC_STATUS WINAPI RpcMgmtIsServerListening(RPC_BINDING_HANDLE Binding)
|
||||
status = RPCRT4_IsServerListening(rpc_binding->Protseq, rpc_binding->Endpoint);
|
||||
}else {
|
||||
EnterCriticalSection(&listen_cs);
|
||||
if (manual_listen_count > 0) status = RPC_S_OK;
|
||||
if (listen_done_event && std_listen) status = RPC_S_OK;
|
||||
LeaveCriticalSection(&listen_cs);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ typedef struct _RpcServerProtseq
|
||||
LPSTR Protseq; /* RO */
|
||||
UINT MaxCalls; /* RO */
|
||||
/* list of listening connections */
|
||||
RpcConnection* conn; /* CS cs */
|
||||
struct list listeners; /* CS cs */
|
||||
struct list connections; /* CS cs */
|
||||
CRITICAL_SECTION cs;
|
||||
|
||||
/* is the server currently listening? */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -160,7 +160,7 @@ reactos/dll/win32/rasapi32 # Synced to WineStaging-1.9.11
|
||||
reactos/dll/win32/resutils # Synced to WineStaging-1.9.11
|
||||
reactos/dll/win32/riched20 # Synced to WineStaging-2.9
|
||||
reactos/dll/win32/riched32 # Synced to WineStaging-1.9.11
|
||||
reactos/dll/win32/rpcrt4 # Synced to WineStaging-2.2
|
||||
reactos/dll/win32/rpcrt4 # Synced to WineStaging-2.9
|
||||
reactos/dll/win32/rsabase # Synced to WineStaging-1.9.11
|
||||
reactos/dll/win32/rsaenh # Synced to WineStaging-2.9
|
||||
reactos/dll/win32/sccbase # Synced to WineStaging-1.9.11
|
||||
|
||||
Reference in New Issue
Block a user