Rob Shearman : rpcrt4: Try to avoid partial named pipe read/
writes by looping.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jan 23 06:18:33 CST 2007
Module: wine
Branch: master
Commit: e6f45145125d99c1ad2d823e57ee752ae202c958
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e6f45145125d99c1ad2d823e57ee752ae202c958
Author: Rob Shearman <rob at codeweavers.com>
Date: Mon Jan 22 21:50:24 2007 +0000
rpcrt4: Try to avoid partial named pipe read/writes by looping.
---
dlls/rpcrt4/rpc_transport.c | 37 ++++++++++++++++++++++++++++---------
1 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c
index 9c07d7d..2776f63 100644
--- a/dlls/rpcrt4/rpc_transport.c
+++ b/dlls/rpcrt4/rpc_transport.c
@@ -354,21 +354,40 @@ static int rpcrt4_conn_np_read(RpcConnec
void *buffer, unsigned int count)
{
RpcConnection_np *npc = (RpcConnection_np *) Connection;
- DWORD dwRead = 0;
- if (!ReadFile(npc->pipe, buffer, count, &dwRead, NULL) &&
- (GetLastError() != ERROR_MORE_DATA))
- return -1;
- return dwRead;
+ char *buf = buffer;
+ BOOL ret = TRUE;
+ unsigned int bytes_left = count;
+
+ while (bytes_left)
+ {
+ DWORD bytes_read;
+ ret = ReadFile(npc->pipe, buf, bytes_left, &bytes_read, NULL);
+ if (!ret || !bytes_read)
+ break;
+ bytes_left -= bytes_read;
+ buf += bytes_read;
+ }
+ return ret ? count : -1;
}
static int rpcrt4_conn_np_write(RpcConnection *Connection,
const void *buffer, unsigned int count)
{
RpcConnection_np *npc = (RpcConnection_np *) Connection;
- DWORD dwWritten = 0;
- if (!WriteFile(npc->pipe, buffer, count, &dwWritten, NULL))
- return -1;
- return dwWritten;
+ const char *buf = buffer;
+ BOOL ret = TRUE;
+ unsigned int bytes_left = count;
+
+ while (bytes_left)
+ {
+ DWORD bytes_written;
+ ret = WriteFile(npc->pipe, buf, count, &bytes_written, NULL);
+ if (!ret || !bytes_written)
+ break;
+ bytes_left -= bytes_written;
+ buf += bytes_written;
+ }
+ return ret ? count : -1;
}
static int rpcrt4_conn_np_close(RpcConnection *Connection)
More information about the wine-cvs
mailing list