All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Weil <sw@weilnetz.de>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Stefan Weil <sw@weilnetz.de>, Michael Tokarev <mjt@tls.msk.ru>,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] iov: Fix do_send_recv() for MinGW (also fixes a build breakage)
Date: Wed, 11 Jul 2012 07:09:05 +0200	[thread overview]
Message-ID: <1341983345-25255-1-git-send-email-sw@weilnetz.de> (raw)

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>
---
 iov.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/iov.c b/iov.c
index 7cc08f0..b333061 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
 }
 
-- 
1.7.10

             reply	other threads:[~2012-07-11  5:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-11  5:09 Stefan Weil [this message]
2012-07-11  5:25 ` [Qemu-devel] [PATCH] iov: Fix do_send_recv() for MinGW (also fixes a build breakage) Michael Tokarev
2012-07-11 12:39   ` Kevin Wolf
2012-07-11 13:15     ` Paolo Bonzini
2012-07-11 13:50       ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1341983345-25255-1-git-send-email-sw@weilnetz.de \
    --to=sw@weilnetz.de \
    --cc=aliguori@us.ibm.com \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.