summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-01-14 16:43:37 +0100
committerVolker Lendecke <vl@samba.org>2009-01-14 17:08:40 +0100
commite1aeb486e87140a51d0a4f7bf91d144dbeff15c7 (patch)
tree6260eb8546baf415bb8bdfefaf8f586a162c07d0
parent11e3388083be7a1be7854cab1603f2dc2905032e (diff)
downloadsamba-e1aeb486e87140a51d0a4f7bf91d144dbeff15c7.tar.gz
samba-e1aeb486e87140a51d0a4f7bf91d144dbeff15c7.tar.bz2
samba-e1aeb486e87140a51d0a4f7bf91d144dbeff15c7.zip
Make rpc_read() match the control flow normally used in Samba
Replace do { .. } while () with a while () { .. }
-rw-r--r--source3/rpc_client/cli_pipe.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index d5d0388107..fbd9b45a3a 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -267,26 +267,27 @@ static NTSTATUS rpc_read(struct rpc_pipe_client *cli,
pdata = prs_data_p(current_pdu) + current_pdu_offset;
- do {
+ while (num_read < size) {
+ ssize_t thistime = 0;
NTSTATUS status;
switch (cli->transport_type) {
case NCACN_NP:
status = rpc_read_np(cli->trans.np.cli,
cli->trans.np.pipe_name,
- cli->trans.np.fnum, pdata,
- size, &num_read);
+ cli->trans.np.fnum,
+ pdata + num_read,
+ size - num_read, &thistime);
break;
case NCACN_IP_TCP:
case NCACN_UNIX_STREAM:
status = NT_STATUS_OK;
- num_read = sys_read(cli->trans.sock.fd, pdata, size);
- if (num_read == -1) {
+ thistime = sys_read(cli->trans.sock.fd,
+ pdata + num_read,
+ size - num_read);
+ if (thistime == -1) {
status = map_nt_error_from_unix(errno);
}
- if (num_read == 0) {
- status = NT_STATUS_END_OF_FILE;
- }
break;
default:
DEBUG(0, ("unknown transport type %d\n",
@@ -294,11 +295,17 @@ static NTSTATUS rpc_read(struct rpc_pipe_client *cli,
return NT_STATUS_INTERNAL_ERROR;
}
- size -= num_read;
- pdata += num_read;
+ if (thistime == 0) {
+ status = NT_STATUS_END_OF_FILE;
+ }
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ num_read += thistime;
- } while (num_read > 0 && size > 0);
- /* && err == (0x80000000 | STATUS_BUFFER_OVERFLOW)); */
+ }
return NT_STATUS_OK;
}