summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2020-01-22 15:14:21 +0000
committerStefan Metzmacher <metze@samba.org>2020-02-06 14:57:41 +0000
commitcc7b909b8bb5ac3874892fdf54bd3e14389f88c4 (patch)
treee0c7720f752c6b805ef412b8e033aae3c955a2d9 /source3
parent8b80145a2c0686cd6b95df89236edeb61192d917 (diff)
downloadsamba-cc7b909b8bb5ac3874892fdf54bd3e14389f88c4.tar.gz
s3:rpclient: simplify rpc_tstream_next_vector()
We always now how many bytes our caller requires, so there's no need to use tstream_pending_bytes(). This makes it possible to read socket_wrapper generated captures again, as wireshark requires the fixed (16 bytes) DCERPC header to be in one TCP packet. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/rpc_client/rpc_transport_tstream.c36
1 files changed, 3 insertions, 33 deletions
diff --git a/source3/rpc_client/rpc_transport_tstream.c b/source3/rpc_client/rpc_transport_tstream.c
index 3f4b616f3e8..3103fa46037 100644
--- a/source3/rpc_client/rpc_transport_tstream.c
+++ b/source3/rpc_client/rpc_transport_tstream.c
@@ -89,7 +89,6 @@ struct rpc_tstream_next_vector_state {
uint8_t *buf;
size_t len;
off_t ofs;
- size_t remaining;
};
static void rpc_tstream_next_vector_init(
@@ -111,8 +110,6 @@ static int rpc_tstream_next_vector(struct tstream_context *stream,
struct rpc_tstream_next_vector_state *state =
(struct rpc_tstream_next_vector_state *)private_data;
struct iovec *vector;
- ssize_t pending;
- size_t wanted;
if (state->ofs == state->len) {
*_vector = NULL;
@@ -120,42 +117,15 @@ static int rpc_tstream_next_vector(struct tstream_context *stream,
return 0;
}
- pending = tstream_pending_bytes(stream);
- if (pending == -1) {
- return -1;
- }
-
- if (pending == 0 && state->ofs != 0) {
- /* return a short read */
- *_vector = NULL;
- *count = 0;
- return 0;
- }
-
- if (pending == 0) {
- /* we want at least one byte and recheck again */
- wanted = 1;
- } else {
- size_t missing = state->len - state->ofs;
- if (pending > missing) {
- /* there's more available */
- state->remaining = pending - missing;
- wanted = missing;
- } else {
- /* read what we can get and recheck in the next cycle */
- wanted = pending;
- }
- }
-
vector = talloc_array(mem_ctx, struct iovec, 1);
if (!vector) {
return -1;
}
- vector[0].iov_base = state->buf + state->ofs;
- vector[0].iov_len = wanted;
+ vector[0].iov_base = state->buf;
+ vector[0].iov_len = state->len;
- state->ofs += wanted;
+ state->ofs = state->len;
*_vector = vector;
*count = 1;