mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:02:58 +00:00
Sync to Wine-20040716:
Mike Hearn <mh@codeweavers.com> - Don't ERR on a used connection being destroyed. - Don't print an extra newline in the olerelay code. - Remove the RPC connection cache as Windows does not allow multiple binds on the same connection. - Correct connection releases on error path in RPCRT4_OpenBinding. svn path=/trunk/; revision=10433
This commit is contained in:
parent
0bc264aea8
commit
9811098a69
3 changed files with 26 additions and 85 deletions
|
@ -46,17 +46,6 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
||||||
|
|
||||||
static RpcConnection* conn_cache;
|
|
||||||
|
|
||||||
static CRITICAL_SECTION conn_cache_cs;
|
|
||||||
static CRITICAL_SECTION_DEBUG critsect_debug =
|
|
||||||
{
|
|
||||||
0, 0, &conn_cache_cs,
|
|
||||||
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
|
||||||
0, 0, { 0, (DWORD)(__FILE__ ": conn_cache_cs") }
|
|
||||||
};
|
|
||||||
static CRITICAL_SECTION conn_cache_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
|
|
||||||
|
|
||||||
LPSTR RPCRT4_strndupA(LPCSTR src, INT slen)
|
LPSTR RPCRT4_strndupA(LPCSTR src, INT slen)
|
||||||
{
|
{
|
||||||
DWORD len;
|
DWORD len;
|
||||||
|
@ -122,11 +111,6 @@ RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPST
|
||||||
NewConnection->Used = Binding;
|
NewConnection->Used = Binding;
|
||||||
NewConnection->MaxTransmissionSize = RPC_MAX_PACKET_SIZE;
|
NewConnection->MaxTransmissionSize = RPC_MAX_PACKET_SIZE;
|
||||||
|
|
||||||
EnterCriticalSection(&conn_cache_cs);
|
|
||||||
NewConnection->Next = conn_cache;
|
|
||||||
conn_cache = NewConnection;
|
|
||||||
LeaveCriticalSection(&conn_cache_cs);
|
|
||||||
|
|
||||||
TRACE("connection: %p\n", NewConnection);
|
TRACE("connection: %p\n", NewConnection);
|
||||||
*Connection = NewConnection;
|
*Connection = NewConnection;
|
||||||
|
|
||||||
|
@ -135,21 +119,7 @@ RPC_STATUS RPCRT4_CreateConnection(RpcConnection** Connection, BOOL server, LPST
|
||||||
|
|
||||||
RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection)
|
RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection)
|
||||||
{
|
{
|
||||||
RpcConnection* PrevConnection;
|
|
||||||
|
|
||||||
TRACE("connection: %p\n", Connection);
|
TRACE("connection: %p\n", Connection);
|
||||||
if (Connection->Used) ERR("connection is still in use\n");
|
|
||||||
|
|
||||||
EnterCriticalSection(&conn_cache_cs);
|
|
||||||
PrevConnection = conn_cache;
|
|
||||||
if (PrevConnection == Connection) {
|
|
||||||
conn_cache = Connection->Next;
|
|
||||||
} else {
|
|
||||||
while (PrevConnection && PrevConnection->Next != Connection)
|
|
||||||
PrevConnection = PrevConnection->Next;
|
|
||||||
if (PrevConnection) PrevConnection->Next = Connection->Next;
|
|
||||||
}
|
|
||||||
LeaveCriticalSection(&conn_cache_cs);
|
|
||||||
|
|
||||||
RPCRT4_CloseConnection(Connection);
|
RPCRT4_CloseConnection(Connection);
|
||||||
RPCRT4_strfree(Connection->Endpoint);
|
RPCRT4_strfree(Connection->Endpoint);
|
||||||
|
@ -159,44 +129,6 @@ RPC_STATUS RPCRT4_DestroyConnection(RpcConnection* Connection)
|
||||||
return RPC_S_OK;
|
return RPC_S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
RPC_STATUS RPCRT4_GetConnection(RpcConnection** Connection, BOOL server, LPSTR Protseq, LPSTR NetworkAddr, LPSTR Endpoint, LPSTR NetworkOptions, RpcBinding* Binding)
|
|
||||||
{
|
|
||||||
RpcConnection* NewConnection;
|
|
||||||
|
|
||||||
if (!server) {
|
|
||||||
EnterCriticalSection(&conn_cache_cs);
|
|
||||||
for (NewConnection = conn_cache; NewConnection; NewConnection = NewConnection->Next) {
|
|
||||||
if (NewConnection->Used) continue;
|
|
||||||
if (NewConnection->server != server) continue;
|
|
||||||
if (Protseq && strcmp(NewConnection->Protseq, Protseq)) continue;
|
|
||||||
if (NetworkAddr && strcmp(NewConnection->NetworkAddr, NetworkAddr)) continue;
|
|
||||||
if (Endpoint && strcmp(NewConnection->Endpoint, Endpoint)) continue;
|
|
||||||
/* this connection fits the bill */
|
|
||||||
NewConnection->Used = Binding;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
LeaveCriticalSection(&conn_cache_cs);
|
|
||||||
if (NewConnection) {
|
|
||||||
TRACE("cached connection: %p\n", NewConnection);
|
|
||||||
*Connection = NewConnection;
|
|
||||||
return RPC_S_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return RPCRT4_CreateConnection(Connection, server, Protseq, NetworkAddr, Endpoint, NetworkOptions, Binding);
|
|
||||||
}
|
|
||||||
|
|
||||||
RPC_STATUS RPCRT4_ReleaseConnection(RpcConnection* Connection)
|
|
||||||
{
|
|
||||||
TRACE("connection: %p\n", Connection);
|
|
||||||
Connection->Used = NULL;
|
|
||||||
if (!Connection->server) {
|
|
||||||
/* cache the open connection for reuse later */
|
|
||||||
/* FIXME: we should probably clean the cache someday */
|
|
||||||
return RPC_S_OK;
|
|
||||||
}
|
|
||||||
return RPCRT4_DestroyConnection(Connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection)
|
RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection)
|
||||||
{
|
{
|
||||||
TRACE("(Connection == ^%p)\n", Connection);
|
TRACE("(Connection == ^%p)\n", Connection);
|
||||||
|
@ -514,7 +446,9 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
|
||||||
if (!Binding->server && Binding->FromConn &&
|
if (!Binding->server && Binding->FromConn &&
|
||||||
memcmp(&Binding->FromConn->ActiveInterface, InterfaceId,
|
memcmp(&Binding->FromConn->ActiveInterface, InterfaceId,
|
||||||
sizeof(RPC_SYNTAX_IDENTIFIER))) {
|
sizeof(RPC_SYNTAX_IDENTIFIER))) {
|
||||||
RPCRT4_ReleaseConnection(Binding->FromConn);
|
|
||||||
|
TRACE("releasing pre-existing connection\n");
|
||||||
|
RPCRT4_DestroyConnection(Binding->FromConn);
|
||||||
Binding->FromConn = NULL;
|
Binding->FromConn = NULL;
|
||||||
} else {
|
} else {
|
||||||
/* we already have an connection with acceptable binding, so use it */
|
/* we already have an connection with acceptable binding, so use it */
|
||||||
|
@ -525,7 +459,7 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create a new connection */
|
/* create a new connection */
|
||||||
RPCRT4_GetConnection(&NewConnection, Binding->server, Binding->Protseq, Binding->NetworkAddr, Binding->Endpoint, NULL, Binding);
|
RPCRT4_CreateConnection(&NewConnection, Binding->server, Binding->Protseq, Binding->NetworkAddr, Binding->Endpoint, NULL, Binding);
|
||||||
*Connection = NewConnection;
|
*Connection = NewConnection;
|
||||||
status = RPCRT4_OpenConnection(NewConnection);
|
status = RPCRT4_OpenConnection(NewConnection);
|
||||||
if (status != RPC_S_OK) {
|
if (status != RPC_S_OK) {
|
||||||
|
@ -547,27 +481,27 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
|
||||||
|
|
||||||
status = RPCRT4_Send(*Connection, hdr, NULL, 0);
|
status = RPCRT4_Send(*Connection, hdr, NULL, 0);
|
||||||
if (status != RPC_S_OK) {
|
if (status != RPC_S_OK) {
|
||||||
RPCRT4_ReleaseConnection(*Connection);
|
RPCRT4_DestroyConnection(*Connection);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
response = HeapAlloc(GetProcessHeap(), 0, RPC_MAX_PACKET_SIZE);
|
response = HeapAlloc(GetProcessHeap(), 0, RPC_MAX_PACKET_SIZE);
|
||||||
if (response == NULL) {
|
if (response == NULL) {
|
||||||
WARN("Can't allocate memory for binding response\n");
|
WARN("Can't allocate memory for binding response\n");
|
||||||
RPCRT4_ReleaseConnection(*Connection);
|
RPCRT4_DestroyConnection(*Connection);
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get a reply */
|
/* get a reply */
|
||||||
if (!ReadFile(NewConnection->conn, response, RPC_MAX_PACKET_SIZE, &count, NULL)) {
|
if (!ReadFile(NewConnection->conn, response, RPC_MAX_PACKET_SIZE, &count, NULL)) {
|
||||||
WARN("ReadFile failed with error %ld\n", GetLastError());
|
WARN("ReadFile failed with error %ld\n", GetLastError());
|
||||||
RPCRT4_ReleaseConnection(*Connection);
|
RPCRT4_DestroyConnection(*Connection);
|
||||||
return RPC_S_PROTOCOL_ERROR;
|
return RPC_S_PROTOCOL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count < sizeof(response_hdr->common)) {
|
if (count < sizeof(response_hdr->common)) {
|
||||||
WARN("received invalid header\n");
|
WARN("received invalid header\n");
|
||||||
RPCRT4_ReleaseConnection(*Connection);
|
RPCRT4_DestroyConnection(*Connection);
|
||||||
return RPC_S_PROTOCOL_ERROR;
|
return RPC_S_PROTOCOL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,13 +511,13 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
|
||||||
response_hdr->common.rpc_ver_minor != RPC_VER_MINOR ||
|
response_hdr->common.rpc_ver_minor != RPC_VER_MINOR ||
|
||||||
response_hdr->common.ptype != PKT_BIND_ACK) {
|
response_hdr->common.ptype != PKT_BIND_ACK) {
|
||||||
WARN("invalid protocol version or rejection packet\n");
|
WARN("invalid protocol version or rejection packet\n");
|
||||||
RPCRT4_ReleaseConnection(Binding->FromConn);
|
RPCRT4_DestroyConnection(*Connection);
|
||||||
return RPC_S_PROTOCOL_ERROR;
|
return RPC_S_PROTOCOL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response_hdr->bind_ack.max_tsize < RPC_MIN_PACKET_SIZE) {
|
if (response_hdr->bind_ack.max_tsize < RPC_MIN_PACKET_SIZE) {
|
||||||
WARN("server doesn't allow large enough packets\n");
|
WARN("server doesn't allow large enough packets\n");
|
||||||
RPCRT4_ReleaseConnection(Binding->FromConn);
|
RPCRT4_DestroyConnection(*Connection);
|
||||||
return RPC_S_PROTOCOL_ERROR;
|
return RPC_S_PROTOCOL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -601,7 +535,7 @@ RPC_STATUS RPCRT4_CloseBinding(RpcBinding* Binding, RpcConnection* Connection)
|
||||||
TRACE("(Binding == ^%p)\n", Binding);
|
TRACE("(Binding == ^%p)\n", Binding);
|
||||||
if (!Connection) return RPC_S_OK;
|
if (!Connection) return RPC_S_OK;
|
||||||
if (Binding->FromConn == Connection) return RPC_S_OK;
|
if (Binding->FromConn == Connection) return RPC_S_OK;
|
||||||
return RPCRT4_ReleaseConnection(Connection);
|
return RPCRT4_DestroyConnection(Connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* utility functions for string composing and parsing */
|
/* utility functions for string composing and parsing */
|
||||||
|
|
|
@ -153,6 +153,7 @@ static RpcServerInterface* RPCRT4_find_interface(UUID* object,
|
||||||
cif = cif->Next;
|
cif = cif->Next;
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&server_cs);
|
LeaveCriticalSection(&server_cs);
|
||||||
|
TRACE("returning %p for %s\n", cif, debugstr_guid(object));
|
||||||
return cif;
|
return cif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,17 +233,18 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, RPC_MESSA
|
||||||
/* FIXME: do more checks! */
|
/* FIXME: do more checks! */
|
||||||
if (hdr->bind.max_tsize < RPC_MIN_PACKET_SIZE ||
|
if (hdr->bind.max_tsize < RPC_MIN_PACKET_SIZE ||
|
||||||
!UuidIsNil(&conn->ActiveInterface.SyntaxGUID, &status)) {
|
!UuidIsNil(&conn->ActiveInterface.SyntaxGUID, &status)) {
|
||||||
|
TRACE("packet size less than min size, or active interface syntax guid non-null\n");
|
||||||
sif = NULL;
|
sif = NULL;
|
||||||
} else {
|
} else {
|
||||||
sif = RPCRT4_find_interface(NULL, &hdr->bind.abstract, FALSE);
|
sif = RPCRT4_find_interface(NULL, &hdr->bind.abstract, FALSE);
|
||||||
}
|
}
|
||||||
if (sif == NULL) {
|
if (sif == NULL) {
|
||||||
TRACE("rejecting bind request\n");
|
TRACE("rejecting bind request on connection %p\n", conn);
|
||||||
/* Report failure to client. */
|
/* Report failure to client. */
|
||||||
response = RPCRT4_BuildBindNackHeader(NDR_LOCAL_DATA_REPRESENTATION,
|
response = RPCRT4_BuildBindNackHeader(NDR_LOCAL_DATA_REPRESENTATION,
|
||||||
RPC_VER_MAJOR, RPC_VER_MINOR);
|
RPC_VER_MAJOR, RPC_VER_MINOR);
|
||||||
} else {
|
} else {
|
||||||
TRACE("accepting bind request\n");
|
TRACE("accepting bind request on connection %p\n", conn);
|
||||||
|
|
||||||
/* accept. */
|
/* accept. */
|
||||||
response = RPCRT4_BuildBindAckHeader(NDR_LOCAL_DATA_REPRESENTATION,
|
response = RPCRT4_BuildBindAckHeader(NDR_LOCAL_DATA_REPRESENTATION,
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
--- rpc_server.c Tue May 4 17:37:56 2004
|
Index: rpc_server.c
|
||||||
+++ rpc_server.c Tue May 4 19:54:24 2004
|
===================================================================
|
||||||
@@ -184,6 +184,7 @@
|
RCS file: /home/wine/wine/dlls/rpcrt4/rpc_server.c,v
|
||||||
|
retrieving revision 1.30
|
||||||
|
diff -u -r1.30 rpc_server.c
|
||||||
|
--- rpc_server.c 17 Jun 2004 19:54:34 -0000 1.30
|
||||||
|
+++ rpc_server.c 8 Aug 2004 21:19:01 -0000
|
||||||
|
@@ -185,6 +185,7 @@
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +13,7 @@
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PRPC_MESSAGE msg;
|
PRPC_MESSAGE msg;
|
||||||
void* buf;
|
void* buf;
|
||||||
@@ -204,20 +205,25 @@
|
@@ -205,20 +206,25 @@
|
||||||
TRACE("returning failure packet\n");
|
TRACE("returning failure packet\n");
|
||||||
return EXCEPTION_EXECUTE_HANDLER;
|
return EXCEPTION_EXECUTE_HANDLER;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +39,7 @@
|
||||||
|
|
||||||
switch (hdr->common.ptype) {
|
switch (hdr->common.ptype) {
|
||||||
case PKT_BIND:
|
case PKT_BIND:
|
||||||
@@ -303,11 +309,15 @@
|
@@ -305,11 +311,15 @@
|
||||||
MAKEWORD(hdr->common.drep[2], hdr->common.drep[3]));
|
MAKEWORD(hdr->common.drep[2], hdr->common.drep[3]));
|
||||||
|
|
||||||
/* dispatch */
|
/* dispatch */
|
||||||
|
@ -50,7 +55,7 @@
|
||||||
|
|
||||||
/* send response packet */
|
/* send response packet */
|
||||||
I_RpcSend(msg);
|
I_RpcSend(msg);
|
||||||
@@ -331,7 +341,9 @@
|
@@ -333,7 +343,9 @@
|
||||||
I_RpcFreeBuffer(msg);
|
I_RpcFreeBuffer(msg);
|
||||||
msg->Buffer = NULL;
|
msg->Buffer = NULL;
|
||||||
RPCRT4_FreeHeader(hdr);
|
RPCRT4_FreeHeader(hdr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue