From mboxrd@z Thu Jan 1 00:00:00 1970 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) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 16 Sep 2011 16:25:41 +0200 Message-Id: <1316183152-5481-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1316183152-5481-1-git-send-email-pbonzini@redhat.com> References: <1316183152-5481-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v2 04/15] coroutine-io: handle zero returns from recv List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: MORITA Kazutaka 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; } -- 1.7.6