From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHS4U-0004QS-BF for qemu-devel@nongnu.org; Tue, 21 Jul 2015 03:34:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZHS4P-0003fT-4V for qemu-devel@nongnu.org; Tue, 21 Jul 2015 03:34:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48573) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHS4O-0003fC-VG for qemu-devel@nongnu.org; Tue, 21 Jul 2015 03:34:33 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 8852BBF9D5 for ; Tue, 21 Jul 2015 07:34:32 +0000 (UTC) From: Paolo Bonzini Date: Tue, 21 Jul 2015 09:34:29 +0200 Message-Id: <1437464069-27508-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] qemu-char: handle EINTR for TCP character devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com Signed-off-by: Paolo Bonzini --- qemu-char.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index b2b43c5..d956f8d 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2798,7 +2798,10 @@ static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len) #ifdef MSG_CMSG_CLOEXEC flags |= MSG_CMSG_CLOEXEC; #endif - ret = recvmsg(s->fd, &msg, flags); + do { + ret = recvmsg(s->fd, &msg, flags); + } while (ret == -1 && errno == EINTR); + if (ret > 0 && s->is_unix) { unix_process_msgfd(chr, &msg); } @@ -2809,7 +2812,13 @@ static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len) static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len) { TCPCharDriver *s = chr->opaque; - return qemu_recv(s->fd, buf, len, 0); + ssize_t ret; + + do { + ret = qemu_recv(s->fd, buf, len, 0); + } while (ret == -1 && socket_error() == EINTR); + + return ret; } #endif -- 2.4.3