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: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2017-05-22 16:03:46 +02:00 committed by Alexandre Julliard
parent b21ca1887f
commit f62b9d69ae
1 changed files with 10 additions and 16 deletions

View File

@ -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)