summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/common-utils.h
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2012-09-05 17:20:05 -0700
committerAnand Avati <avati@redhat.com>2012-12-04 14:46:04 -0800
commit98879ebdddd4ca77440defad6a73acf4fa1e75ab (patch)
tree041cfce881b40d22758a423542e380578dd8112f /libglusterfs/src/common-utils.h
parent741766c708f2a246854584c064d63d3fba67be90 (diff)
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 <avati@redhat.com> Reviewed-on: http://review.gluster.org/3855 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'libglusterfs/src/common-utils.h')
-rw-r--r--libglusterfs/src/common-utils.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index 6d46a997105..75692309e14 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -349,6 +349,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)
{