Jacek Caban : rpcrt4: Simplify rpcrt4_conn_np_write implementation.
Alexandre Julliard
julliard at winehq.org
Mon May 22 15:54:04 CDT 2017
Module: wine
Branch: master
Commit: f62b9d69ae06df67cce3e0b6d7eb2a5470470290
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f62b9d69ae06df67cce3e0b6d7eb2a5470470290
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon May 22 16:03:46 2017 +0200
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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/rpcrt4/rpc_transport.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c
index 60975ca..bc2f4a3 100644
--- a/dlls/rpcrt4/rpc_transport.c
+++ b/dlls/rpcrt4/rpc_transport.c
@@ -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)
More information about the wine-cvs
mailing list