]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:rpclient: simplify rpc_tstream_next_vector()
authorStefan Metzmacher <metze@samba.org>
Wed, 22 Jan 2020 15:14:21 +0000 (15:14 +0000)
committerStefan Metzmacher <metze@samba.org>
Thu, 6 Feb 2020 14:57:41 +0000 (14:57 +0000)
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>
source3/rpc_client/rpc_transport_tstream.c

index 3f4b616f3e816f4caded7903edd0ade85152bc7a..3103fa4603746a96a22c04ebaf27e1efe02d7c4d 100644 (file)
@@ -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;