summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/common-utils.h3
-rw-r--r--rpc/rpc-transport/socket/src/socket.c4
2 files changed, 5 insertions, 2 deletions
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index 05e4d5b348d..500d34237f0 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -27,6 +27,7 @@
#ifndef GF_BSD_HOST_OS
#include <alloca.h>
#endif
+#include <limits.h>
void trap (void);
@@ -258,6 +259,8 @@ union gf_sock_union {
#define GF_HIDDEN_PATH ".glusterfs"
+#define IOV_MIN(n) min(IOV_MAX,n)
+
static inline void
iov_free (struct iovec *vector, int count)
{
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 93da3f29690..f9df4ac1d1e 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -327,7 +327,7 @@ __socket_ssl_readv (rpc_transport_t *this, struct iovec *opvector, int opcount)
if (priv->use_ssl) {
ret = ssl_read_one (this, opvector->iov_base, opvector->iov_len);
} else {
- ret = readv (sock, opvector, opcount);
+ ret = readv (sock, opvector, IOV_MIN(opcount));
}
return ret;
@@ -477,7 +477,7 @@ __socket_rwv (rpc_transport_t *this, struct iovec *vector, int count,
opvector->iov_base, opvector->iov_len);
}
else {
- ret = writev (sock, opvector, opcount);
+ ret = writev (sock, opvector, IOV_MIN(opcount));
}
if (ret == 0 || (ret == -1 && errno == EAGAIN)) {