Commit f62b9d69 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

rpcrt4: Simplify rpcrt4_conn_np_write implementation.

There is no need for the loop. Named pipes always do complete writes. Also use NtWriteFile like we do for reading to not mess with GetLastError(). Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent b21ca188
......@@ -429,24 +429,18 @@ static int rpcrt4_conn_np_read(RpcConnection *Connection,
return count;
}
static int rpcrt4_conn_np_write(RpcConnection *Connection,
const void *buffer, unsigned int count)
static int rpcrt4_conn_np_write(RpcConnection *conn, const void *buffer, unsigned int count)
{
RpcConnection_np *npc = (RpcConnection_np *) Connection;
const char *buf = buffer;
BOOL ret = TRUE;
unsigned int bytes_left = count;
RpcConnection_np *connection = (RpcConnection_np *) conn;
IO_STATUS_BLOCK io_status;
NTSTATUS status;
while (bytes_left)
{
DWORD bytes_written;
ret = WriteFile(npc->pipe, buf, bytes_left, &bytes_written, NULL);
if (!ret || !bytes_written)
break;
bytes_left -= bytes_written;
buf += bytes_written;
}
return ret ? count : -1;
status = NtWriteFile(connection->pipe, NULL, NULL, NULL, &io_status, buffer, count, NULL, NULL);
if (status)
return -1;
assert(io_status.Information == count);
return count;
}
static int rpcrt4_conn_np_close(RpcConnection *Connection)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment