aboutsummaryrefslogtreecommitdiff
path: root/iov.c
diff options
context:
space:
mode:
authorStefan Weil <sw@weilnetz.de>2012-07-11 07:09:05 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2012-07-11 08:51:50 -0500
commitc0958559b1a589a0d189c45ea1adaa6b345f4256 (patch)
treef8ea281b38d79b1b96ca77e891a93370ab48a219 /iov.c
parent31783203c3b74c11015b20194d57dada559940cf (diff)
iov: Fix do_send_recv() for MinGW (also fixes a build breakage)
Commit 25e5e4c7 broke compilation for non POSIX hosts (e.g. MinGW) because it partially replaced "ret" by "count". It also changed the handling of EINTR in a wrong way. The patch restores the old code for these two changes. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'iov.c')
-rw-r--r--iov.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/iov.c b/iov.c
index 7cc08f0fe4..b3330610bb 100644
--- a/iov.c
+++ b/iov.c
@@ -114,9 +114,9 @@ do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
#else
/* else send piece-by-piece */
/*XXX Note: windows has WSASend() and WSARecv() */
- unsigned i;
- size_t count = 0;
- for (i = 0; i < iov_cnt; ++i) {
+ unsigned i = 0;
+ ssize_t ret = 0;
+ while (i < iov_cnt) {
ssize_t r = do_send
? send(sockfd, iov[i].iov_base, iov[i].iov_len, 0)
: recv(sockfd, iov[i].iov_base, iov[i].iov_len, 0);
@@ -130,12 +130,13 @@ do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
/* else it is some "other" error,
* only return if there was no data processed. */
if (ret == 0) {
- return -1;
+ ret = -1;
}
break;
}
+ i++;
}
- return count;
+ return ret;
#endif
}