From: Stefan Metzmacher Date: Wed, 22 Jan 2020 15:14:21 +0000 (+0000) Subject: s3:rpclient: simplify rpc_tstream_next_vector() X-Git-Tag: ldb-2.1.1~162 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc7b909b8bb5ac3874892fdf54bd3e14389f88c4;p=thirdparty%2Fsamba.git 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 Reviewed-by: Andreas Schneider --- 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;