rpcrt4: Store listening pipe name in RpcConnection_np.

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-31 17:30:23 +02:00 committed by Alexandre Julliard
parent 5c81f8295e
commit 5c2083fd22
1 changed files with 24 additions and 35 deletions

View File

@ -67,6 +67,7 @@ typedef struct _RpcConnection_np
RpcConnection common; RpcConnection common;
HANDLE pipe; HANDLE pipe;
HANDLE listen_event; HANDLE listen_event;
char *listen_pipe;
IO_STATUS_BLOCK io_status; IO_STATUS_BLOCK io_status;
HANDLE event_cache; HANDLE event_cache;
BOOL read_closed; BOOL read_closed;
@ -91,16 +92,18 @@ static void release_np_event(RpcConnection_np *connection, HANDLE event)
CloseHandle(event); CloseHandle(event);
} }
static RPC_STATUS rpcrt4_conn_create_pipe(RpcConnection *Connection, LPCSTR pname) static RPC_STATUS rpcrt4_conn_create_pipe(RpcConnection *conn)
{ {
RpcConnection_np *npc = (RpcConnection_np *) Connection; RpcConnection_np *connection = (RpcConnection_np *) conn;
TRACE("listening on %s\n", pname);
npc->pipe = CreateNamedPipeA(pname, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, TRACE("listening on %s\n", connection->listen_pipe);
connection->pipe = CreateNamedPipeA(connection->listen_pipe, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE,
PIPE_UNLIMITED_INSTANCES, PIPE_UNLIMITED_INSTANCES,
RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE, 5000, NULL); RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE, 5000, NULL);
if (npc->pipe == INVALID_HANDLE_VALUE) { if (connection->pipe == INVALID_HANDLE_VALUE)
{
WARN("CreateNamedPipe failed with error %d\n", GetLastError()); WARN("CreateNamedPipe failed with error %d\n", GetLastError());
if (GetLastError() == ERROR_FILE_EXISTS) if (GetLastError() == ERROR_FILE_EXISTS)
return RPC_S_DUPLICATE_ENDPOINT; return RPC_S_DUPLICATE_ENDPOINT;
@ -108,8 +111,6 @@ static RPC_STATUS rpcrt4_conn_create_pipe(RpcConnection *Connection, LPCSTR pnam
return RPC_S_CANT_CREATE_ENDPOINT; return RPC_S_CANT_CREATE_ENDPOINT;
} }
/* Note: we don't call ConnectNamedPipe here because it must be done in the
* server thread as the thread must be alertable */
return RPC_S_OK; return RPC_S_OK;
} }
@ -203,7 +204,6 @@ static RPC_STATUS rpcrt4_ncalrpc_open(RpcConnection* Connection)
static RPC_STATUS rpcrt4_protseq_ncalrpc_open_endpoint(RpcServerProtseq* protseq, const char *endpoint) static RPC_STATUS rpcrt4_protseq_ncalrpc_open_endpoint(RpcServerProtseq* protseq, const char *endpoint)
{ {
RPC_STATUS r; RPC_STATUS r;
LPSTR pname;
RpcConnection *Connection; RpcConnection *Connection;
char generated_endpoint[22]; char generated_endpoint[22];
@ -222,9 +222,8 @@ static RPC_STATUS rpcrt4_protseq_ncalrpc_open_endpoint(RpcServerProtseq* protseq
if (r != RPC_S_OK) if (r != RPC_S_OK)
return r; return r;
pname = ncalrpc_pipe_name(Connection->Endpoint); ((RpcConnection_np*)Connection)->listen_pipe = ncalrpc_pipe_name(Connection->Endpoint);
r = rpcrt4_conn_create_pipe(Connection, pname); r = rpcrt4_conn_create_pipe(Connection);
I_RpcFree(pname);
EnterCriticalSection(&protseq->cs); EnterCriticalSection(&protseq->cs);
list_add_head(&protseq->listeners, &Connection->protseq_entry); list_add_head(&protseq->listeners, &Connection->protseq_entry);
@ -265,7 +264,6 @@ static RPC_STATUS rpcrt4_ncacn_np_open(RpcConnection* Connection)
static RPC_STATUS rpcrt4_protseq_ncacn_np_open_endpoint(RpcServerProtseq *protseq, const char *endpoint) static RPC_STATUS rpcrt4_protseq_ncacn_np_open_endpoint(RpcServerProtseq *protseq, const char *endpoint)
{ {
RPC_STATUS r; RPC_STATUS r;
LPSTR pname;
RpcConnection *Connection; RpcConnection *Connection;
char generated_endpoint[26]; char generated_endpoint[26];
@ -284,9 +282,8 @@ static RPC_STATUS rpcrt4_protseq_ncacn_np_open_endpoint(RpcServerProtseq *protse
if (r != RPC_S_OK) if (r != RPC_S_OK)
return r; return r;
pname = ncacn_pipe_name(Connection->Endpoint); ((RpcConnection_np*)Connection)->listen_pipe = ncacn_pipe_name(Connection->Endpoint);
r = rpcrt4_conn_create_pipe(Connection, pname); r = rpcrt4_conn_create_pipe(Connection);
I_RpcFree(pname);
EnterCriticalSection(&protseq->cs); EnterCriticalSection(&protseq->cs);
list_add_head(&protseq->listeners, &Connection->protseq_entry); list_add_head(&protseq->listeners, &Connection->protseq_entry);
@ -310,13 +307,9 @@ static RPC_STATUS rpcrt4_ncacn_np_handoff(RpcConnection *old_conn, RpcConnection
{ {
DWORD len = MAX_COMPUTERNAME_LENGTH + 1; DWORD len = MAX_COMPUTERNAME_LENGTH + 1;
RPC_STATUS status; RPC_STATUS status;
LPSTR pname;
rpcrt4_conn_np_handoff((RpcConnection_np *)old_conn, (RpcConnection_np *)new_conn); rpcrt4_conn_np_handoff((RpcConnection_np *)old_conn, (RpcConnection_np *)new_conn);
status = rpcrt4_conn_create_pipe(old_conn);
pname = ncacn_pipe_name(old_conn->Endpoint);
status = rpcrt4_conn_create_pipe(old_conn, pname);
I_RpcFree(pname);
/* Store the local computer name as the NetworkAddr for ncacn_np as long as /* Store the local computer name as the NetworkAddr for ncacn_np as long as
* we don't support named pipes over the network. */ * we don't support named pipes over the network. */
@ -361,15 +354,11 @@ static RPC_STATUS rpcrt4_ncalrpc_handoff(RpcConnection *old_conn, RpcConnection
{ {
DWORD len = MAX_COMPUTERNAME_LENGTH + 1; DWORD len = MAX_COMPUTERNAME_LENGTH + 1;
RPC_STATUS status; RPC_STATUS status;
LPSTR pname;
TRACE("%s\n", old_conn->Endpoint); TRACE("%s\n", old_conn->Endpoint);
rpcrt4_conn_np_handoff((RpcConnection_np *)old_conn, (RpcConnection_np *)new_conn); rpcrt4_conn_np_handoff((RpcConnection_np *)old_conn, (RpcConnection_np *)new_conn);
status = rpcrt4_conn_create_pipe(old_conn);
pname = ncalrpc_pipe_name(old_conn->Endpoint);
status = rpcrt4_conn_create_pipe(old_conn, pname);
I_RpcFree(pname);
/* Store the local computer name as the NetworkAddr for ncalrpc. */ /* Store the local computer name as the NetworkAddr for ncalrpc. */
new_conn->NetworkAddr = HeapAlloc(GetProcessHeap(), 0, len); new_conn->NetworkAddr = HeapAlloc(GetProcessHeap(), 0, len);