From patchwork Wed Jul 11 05:09:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Weil X-Patchwork-Id: 170351 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 383722C0205 for ; Wed, 11 Jul 2012 15:09:23 +1000 (EST) Received: from localhost ([::1]:60404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SopAt-0006ZI-59 for incoming@patchwork.ozlabs.org; Wed, 11 Jul 2012 01:09:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SopAk-0006ZB-OV for qemu-devel@nongnu.org; Wed, 11 Jul 2012 01:09:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SopAi-0006bA-Rp for qemu-devel@nongnu.org; Wed, 11 Jul 2012 01:09:10 -0400 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:45665) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SopAi-0006b3-LZ for qemu-devel@nongnu.org; Wed, 11 Jul 2012 01:09:08 -0400 Received: from localhost (v220110690675601.yourvserver.net.local [127.0.0.1]) by v220110690675601.yourvserver.net (Postfix) with ESMTP id F412972800C0; Wed, 11 Jul 2012 07:09:06 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at weilnetz.de Received: from v220110690675601.yourvserver.net ([127.0.0.1]) by localhost (v220110690675601.yourvserver.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0P7tw1tTXg6G; Wed, 11 Jul 2012 07:09:06 +0200 (CEST) Received: by v220110690675601.yourvserver.net (Postfix, from userid 1000) id 71A9472800C1; Wed, 11 Jul 2012 07:09:06 +0200 (CEST) From: Stefan Weil To: Anthony Liguori Date: Wed, 11 Jul 2012 07:09:05 +0200 Message-Id: <1341983345-25255-1-git-send-email-sw@weilnetz.de> X-Mailer: git-send-email 1.7.10 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 78.47.199.172 Cc: Stefan Weil , Michael Tokarev , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] iov: Fix do_send_recv() for MinGW (also fixes a build breakage) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Signed-off-by: Michael Tokarev --- 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 }