From patchwork Fri Sep 16 14:25:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 114930 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 70A4FB70C0 for ; Sat, 17 Sep 2011 00:26:44 +1000 (EST) Received: from localhost ([::1]:43492 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4ZNI-0003fI-7P for incoming@patchwork.ozlabs.org; Fri, 16 Sep 2011 10:26:40 -0400 Received: from eggs.gnu.org ([140.186.70.92]:58696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4ZMy-00039e-3q for qemu-devel@nongnu.org; Fri, 16 Sep 2011 10:26:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R4ZMt-0004zr-E3 for qemu-devel@nongnu.org; Fri, 16 Sep 2011 10:26:20 -0400 Received: from mail-wy0-f175.google.com ([74.125.82.175]:34955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4ZMt-0004zd-8k for qemu-devel@nongnu.org; Fri, 16 Sep 2011 10:26:15 -0400 Received: by wyh5 with SMTP id 5so2976576wyh.34 for ; Fri, 16 Sep 2011 07:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=Xpn7evdFd6H/0E0gS+/cE3ujYmbmLr3aII8o73JZBDg=; b=Xoj2G2K2HlStYbmDevf57GW8i3c/tdnrVfI6eCJCGx0FUnApyMieUQUlK6a/lAAljv R/hmzw1+DT4x5oM/U0An3t/9cMEnfePSB+Yh1zUSpyIdVEqk39ubvTN/dC8v1TtyOr73 n8kO/+OMLRjPBInCZ06YxTfKcxt6GD2X7qYSQ= Received: by 10.227.145.135 with SMTP id d7mr409471wbv.48.1316183173938; Fri, 16 Sep 2011 07:26:13 -0700 (PDT) Received: from localhost.localdomain (93-34-199-31.ip51.fastwebnet.it. [93.34.199.31]) by mx.google.com with ESMTPS id ek13sm12701198wbb.23.2011.09.16.07.26.12 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Sep 2011 07:26:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 16 Sep 2011 16:25:41 +0200 Message-Id: <1316183152-5481-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1316183152-5481-1-git-send-email-pbonzini@redhat.com> References: <1316183152-5481-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.175 Cc: MORITA Kazutaka Subject: [Qemu-devel] [PATCH v2 04/15] coroutine-io: handle zero returns from recv 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 When the other side is shutdown, read returns zero (writes return EPIPE). In this case, care must be taken to avoid infinite loops. This error was already present in sheepdog. Cc: MORITA Kazutaka Signed-off-by: Paolo Bonzini --- cutils.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/cutils.c b/cutils.c index b302020..295187f 100644 --- a/cutils.c +++ b/cutils.c @@ -501,8 +501,11 @@ static int do_sendv_recvv(int sockfd, struct iovec *iov, int len, int offset, } break; } - iovlen--, p++; + if (rc == 0) { + break; + } ret += rc; + iovlen--, p++; } #endif } @@ -567,6 +570,9 @@ int coroutine_fn qemu_co_sendv(int sockfd, struct iovec *iov, } break; } + if (ret == 0) { + break; + } total += ret, len -= ret; }