From 98879ebdddd4ca77440defad6a73acf4fa1e75ab Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Wed, 5 Sep 2012 17:20:05 -0700 Subject: rpc-transport/socket: implement read-ahead of RPC headers This reduces the number of read() system calls on the socket to complete the full RPC fragment reading. Change-Id: I421a53af195ead4aad70e09e0172a61ad7912d83 BUG: 821087 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.org/3855 Tested-by: Gluster Build System Reviewed-by: Jeff Darcy Reviewed-by: Amar Tumballi --- libglusterfs/src/common-utils.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index 6d46a9971..75692309e 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -348,6 +348,28 @@ iov_unload (char *buf, const struct iovec *vector, int count) } +static inline size_t +iov_load (const struct iovec *vector, int count, char *buf, int size) +{ + size_t left = size; + size_t cp = 0; + int ret = 0; + int i = 0; + + while (left && i < count) { + cp = min (vector[i].iov_len, left); + if (vector[i].iov_base != buf + (size - left)) + memcpy (vector[i].iov_base, buf + (size - left), cp); + ret += cp; + left -= cp; + if (left) + i++; + } + + return ret; +} + + static inline size_t iov_copy (const struct iovec *dst, int dcnt, const struct iovec *src, int scnt) -- cgit