- Fix a bad use of HeapRealloc.
- Fix error return codes. - Improve traces.
This commit is contained in:
parent
766fc7cc9c
commit
d1d89a64a6
|
@ -212,12 +212,12 @@ RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection)
|
|||
memset(&Connection->ovl, 0, sizeof(Connection->ovl));
|
||||
Connection->ovl.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
|
||||
if (!ConnectNamedPipe(Connection->conn, &Connection->ovl)) {
|
||||
DWORD err = GetLastError();
|
||||
if (err == ERROR_PIPE_CONNECTED) {
|
||||
WARN("Couldn't ConnectNamedPipe (error was %ld)\n", GetLastError());
|
||||
if (GetLastError() == ERROR_PIPE_CONNECTED) {
|
||||
SetEvent(Connection->ovl.hEvent);
|
||||
return RPC_S_OK;
|
||||
}
|
||||
return err;
|
||||
return RPC_S_SERVER_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
/* protseq=ncacn_np: named pipes */
|
||||
|
@ -233,12 +233,12 @@ RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection)
|
|||
memset(&Connection->ovl, 0, sizeof(Connection->ovl));
|
||||
Connection->ovl.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
|
||||
if (!ConnectNamedPipe(Connection->conn, &Connection->ovl)) {
|
||||
DWORD err = GetLastError();
|
||||
if (err == ERROR_PIPE_CONNECTED) {
|
||||
WARN("Couldn't ConnectNamedPipe (error was %ld)\n", GetLastError());
|
||||
if (GetLastError() == ERROR_PIPE_CONNECTED) {
|
||||
SetEvent(Connection->ovl.hEvent);
|
||||
return RPC_S_OK;
|
||||
}
|
||||
return err;
|
||||
return RPC_S_SERVER_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -267,12 +267,12 @@ RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection)
|
|||
if (err == ERROR_PIPE_BUSY) continue;
|
||||
TRACE("connection failed, error=%lx\n", err);
|
||||
HeapFree(GetProcessHeap(), 0, pname);
|
||||
return err;
|
||||
return RPC_S_SERVER_TOO_BUSY;
|
||||
} else {
|
||||
err = GetLastError();
|
||||
TRACE("connection failed, error=%lx\n", err);
|
||||
HeapFree(GetProcessHeap(), 0, pname);
|
||||
return err;
|
||||
return RPC_S_SERVER_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,10 @@ RPC_STATUS RPCRT4_OpenConnection(RpcConnection* Connection)
|
|||
* the doc says that it is returned to the app */
|
||||
TRACE("connection failed, error=%lx\n", err);
|
||||
HeapFree(GetProcessHeap(), 0, pname);
|
||||
return err;
|
||||
if (err == ERROR_PIPE_BUSY)
|
||||
return RPC_S_SERVER_TOO_BUSY;
|
||||
else
|
||||
return RPC_S_SERVER_UNAVAILABLE;
|
||||
}
|
||||
|
||||
/* success */
|
||||
|
|
|
@ -49,7 +49,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
|||
RPC_STATUS WINAPI I_RpcGetBuffer(PRPC_MESSAGE pMsg)
|
||||
{
|
||||
RpcBinding* bind = (RpcBinding*)pMsg->Handle;
|
||||
void* buf;
|
||||
|
||||
TRACE("(%p): BufferLength=%d\n", pMsg, pMsg->BufferLength);
|
||||
/* FIXME: pfnAllocate? */
|
||||
|
@ -57,14 +56,15 @@ RPC_STATUS WINAPI I_RpcGetBuffer(PRPC_MESSAGE pMsg)
|
|||
/* it turns out that the original buffer data must still be available
|
||||
* while the RPC server is marshalling a reply, so we should not deallocate
|
||||
* it, we'll leave deallocating the original buffer to the RPC server */
|
||||
buf = HeapAlloc(GetProcessHeap(), 0, pMsg->BufferLength);
|
||||
pMsg->Buffer = HeapAlloc(GetProcessHeap(), 0, pMsg->BufferLength);
|
||||
} else {
|
||||
buf = HeapReAlloc(GetProcessHeap(), 0, pMsg->Buffer, pMsg->BufferLength);
|
||||
if (pMsg->Buffer)
|
||||
HeapFree(GetProcessHeap(), 0, pMsg->Buffer);
|
||||
pMsg->Buffer = HeapAlloc(GetProcessHeap(), 0, pMsg->BufferLength);
|
||||
}
|
||||
TRACE("Buffer=%p\n", buf);
|
||||
if (buf) pMsg->Buffer = buf;
|
||||
TRACE("Buffer=%p\n", pMsg->Buffer);
|
||||
/* FIXME: which errors to return? */
|
||||
return buf ? S_OK : E_OUTOFMEMORY;
|
||||
return pMsg->Buffer ? S_OK : E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -132,11 +132,20 @@ RPC_STATUS WINAPI I_RpcSend(PRPC_MESSAGE pMsg)
|
|||
|
||||
/* transmit packet */
|
||||
if (!WriteFile(conn->conn, &hdr, sizeof(hdr), NULL, NULL)) {
|
||||
status = GetLastError();
|
||||
WARN("WriteFile failed with error %ld\n", GetLastError());
|
||||
status = RPC_S_PROTOCOL_ERROR;
|
||||
goto fail;
|
||||
}
|
||||
if (pMsg->BufferLength && !WriteFile(conn->conn, pMsg->Buffer, pMsg->BufferLength, NULL, NULL)) {
|
||||
status = GetLastError();
|
||||
|
||||
if (!pMsg->BufferLength)
|
||||
{
|
||||
status = RPC_S_OK;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!WriteFile(conn->conn, pMsg->Buffer, pMsg->BufferLength, NULL, NULL)) {
|
||||
WARN("WriteFile failed with error %ld\n", GetLastError());
|
||||
status = RPC_S_PROTOCOL_ERROR;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -184,17 +193,20 @@ RPC_STATUS WINAPI I_RpcReceive(PRPC_MESSAGE pMsg)
|
|||
if (!ReadFile(conn->conn, &hdr, sizeof(hdr), &dwRead, &conn->ovl)) {
|
||||
DWORD err = GetLastError();
|
||||
if (err != ERROR_IO_PENDING) {
|
||||
status = err;
|
||||
WARN("ReadFile failed with error %ld\n", err);
|
||||
status = RPC_S_PROTOCOL_ERROR;
|
||||
goto fail;
|
||||
}
|
||||
if (!GetOverlappedResult(conn->conn, &conn->ovl, &dwRead, TRUE)) {
|
||||
status = GetLastError();
|
||||
WARN("ReadFile failed with error %ld\n", GetLastError());
|
||||
status = RPC_S_PROTOCOL_ERROR;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (!ReadFile(conn->conn, &hdr, sizeof(hdr), &dwRead, NULL)) {
|
||||
status = GetLastError();
|
||||
WARN("ReadFile failed with error %ld\n", GetLastError());
|
||||
status = RPC_S_PROTOCOL_ERROR;
|
||||
goto fail;
|
||||
}
|
||||
#endif
|
||||
|
@ -210,19 +222,21 @@ RPC_STATUS WINAPI I_RpcReceive(PRPC_MESSAGE pMsg)
|
|||
if (!pMsg->BufferLength) dwRead = 0; else
|
||||
#ifdef OVERLAPPED_WORKS
|
||||
if (!ReadFile(conn->conn, pMsg->Buffer, hdr.len, &dwRead, &conn->ovl)) {
|
||||
DWORD err = GetLastError();
|
||||
if (err != ERROR_IO_PENDING) {
|
||||
status = err;
|
||||
if (GetLastError() != ERROR_IO_PENDING) {
|
||||
WARN("ReadFile failed with error %ld\n", GetLastError());
|
||||
status = RPC_S_PROTOCOL_ERROR;
|
||||
goto fail;
|
||||
}
|
||||
if (!GetOverlappedResult(conn->conn, &conn->ovl, &dwRead, TRUE)) {
|
||||
status = GetLastError();
|
||||
WARN("ReadFile failed with error %ld\n", GetLastError());
|
||||
status = RPC_S_PROTOCOL_ERROR;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (!ReadFile(conn->conn, pMsg->Buffer, hdr.len, &dwRead, NULL)) {
|
||||
status = GetLastError();
|
||||
WARN("ReadFile failed with error %ld\n", GetLastError());
|
||||
status = RPC_S_PROTOCOL_ERROR;
|
||||
goto fail;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -194,6 +194,8 @@ static WINE_EXCEPTION_FILTER(rpc_filter)
|
|||
msg->BufferLength = sizeof(DWORD);
|
||||
I_RpcGetBuffer(msg);
|
||||
*(DWORD*)msg->Buffer = GetExceptionCode();
|
||||
WARN("exception caught with code 0x%08lx = %ld\n", *(DWORD*)msg->Buffer, *(DWORD*)msg->Buffer);
|
||||
TRACE("returning failure packet\n");
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
|
@ -249,7 +251,6 @@ static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr, void* buf
|
|||
if (func) func(&msg);
|
||||
} __EXCEPT(rpc_filter) {
|
||||
/* failure packet was created in rpc_filter */
|
||||
TRACE("exception caught, returning failure packet\n");
|
||||
} __ENDTRY
|
||||
|
||||
/* send response packet */
|
||||
|
|
Loading…
Reference in New Issue