rpcrt4: Store all active connections in RpcServerProtseq.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2017-05-23 17:39:39 +02:00 committed by Alexandre Julliard
parent dae30652e6
commit ef267f115f
3 changed files with 23 additions and 11 deletions

View File

@ -946,6 +946,7 @@ static RPC_STATUS alloc_serverprotoseq(UINT MaxCalls, const char *Protseq, RpcSe
(*ps)->ops = ops; (*ps)->ops = ops;
(*ps)->MaxCalls = 0; (*ps)->MaxCalls = 0;
list_init(&(*ps)->listeners); list_init(&(*ps)->listeners);
list_init(&(*ps)->connections);
InitializeCriticalSection(&(*ps)->cs); InitializeCriticalSection(&(*ps)->cs);
(*ps)->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcServerProtseq.cs"); (*ps)->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcServerProtseq.cs");
(*ps)->is_listening = FALSE; (*ps)->is_listening = FALSE;

View File

@ -34,6 +34,7 @@ typedef struct _RpcServerProtseq
UINT MaxCalls; /* RO */ UINT MaxCalls; /* RO */
/* list of listening connections */ /* list of listening connections */
struct list listeners; /* CS cs */ struct list listeners; /* CS cs */
struct list connections; /* CS cs */
CRITICAL_SECTION cs; CRITICAL_SECTION cs;
/* is the server currently listening? */ /* is the server currently listening? */

View File

@ -58,7 +58,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(rpc); WINE_DEFAULT_DEBUG_CHANNEL(rpc);
static RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* OldConnection); static RpcConnection *rpcrt4_spawn_connection(RpcConnection *old_connection);
/**** ncacn_np support ****/ /**** ncacn_np support ****/
@ -744,7 +744,7 @@ static int rpcrt4_protseq_np_wait_for_new_connection(RpcServerProtseq *protseq,
release_np_event(conn, conn->listen_event); release_np_event(conn, conn->listen_event);
conn->listen_event = NULL; conn->listen_event = NULL;
if (conn->io_status.Status == STATUS_SUCCESS || conn->io_status.Status == STATUS_PIPE_CONNECTED) if (conn->io_status.Status == STATUS_SUCCESS || conn->io_status.Status == STATUS_PIPE_CONNECTED)
RPCRT4_SpawnConnection(&cconn, &conn->common); cconn = rpcrt4_spawn_connection(&conn->common);
else else
ERR("listen failed %x\n", conn->io_status.Status); ERR("listen failed %x\n", conn->io_status.Status);
break; break;
@ -1595,7 +1595,7 @@ static int rpcrt4_protseq_sock_wait_for_new_connection(RpcServerProtseq *protseq
{ {
if (b_handle == conn->sock_event) if (b_handle == conn->sock_event)
{ {
RPCRT4_SpawnConnection(&cconn, &conn->common); cconn = rpcrt4_spawn_connection(&conn->common);
break; break;
} }
} }
@ -3311,16 +3311,26 @@ RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server,
return RPC_S_OK; return RPC_S_OK;
} }
static RPC_STATUS RPCRT4_SpawnConnection(RpcConnection** Connection, RpcConnection* OldConnection) static RpcConnection *rpcrt4_spawn_connection(RpcConnection *old_connection)
{ {
RPC_STATUS err; RpcConnection *connection;
RPC_STATUS err;
err = RPCRT4_CreateConnection(Connection, OldConnection->server, rpcrt4_conn_get_name(OldConnection), err = RPCRT4_CreateConnection(&connection, old_connection->server, rpcrt4_conn_get_name(old_connection),
OldConnection->NetworkAddr, OldConnection->Endpoint, NULL, old_connection->NetworkAddr, old_connection->Endpoint, NULL,
OldConnection->AuthInfo, OldConnection->QOS, OldConnection->CookieAuth); old_connection->AuthInfo, old_connection->QOS, old_connection->CookieAuth);
if (err == RPC_S_OK) if (err != RPC_S_OK)
rpcrt4_conn_handoff(OldConnection, *Connection); return NULL;
return err;
rpcrt4_conn_handoff(old_connection, connection);
if (old_connection->protseq)
{
EnterCriticalSection(&old_connection->protseq->cs);
connection->protseq = old_connection->protseq;
list_add_tail(&old_connection->protseq->connections, &connection->protseq_entry);
LeaveCriticalSection(&old_connection->protseq->cs);
}
return connection;
} }
RpcConnection *RPCRT4_GrabConnection( RpcConnection *conn ) RpcConnection *RPCRT4_GrabConnection( RpcConnection *conn )