Received: from eggs.gnu.org ([2001:4830:134:3::10]:36766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUrUx-0003Di-85 for qemu-devel@nongnu.org; Fri, 19 Sep 2014 02:16:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUrUr-0008U8-44 for qemu-devel@nongnu.org; Fri, 19 Sep 2014 02:16:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11076) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUrUq-0008TY-Rl for qemu-devel@nongnu.org; Fri, 19 Sep 2014 02:16:45 -0400 From: Markus Armbruster References: <1411039293-18988-1-git-send-email-zifeitong@gmail.com> <878ulhruvo.fsf@blackfin.pond.sub.org> Date: Fri, 19 Sep 2014 08:16:29 +0200 In-Reply-To: (Zifei Tong's message of "Fri, 19 Sep 2014 12:55:53 +0800") Message-ID: <8738bof83m.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2] qemu-char: Do not disconnect when there's data for reading List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Zifei Tong Cc: Kirill Batuzov , qemu-devel@nongnu.org, Nikolay Nikolaev , Anthony Liguori Zifei Tong writes: > Hi Markus, > > On Thu, Sep 18, 2014 at 8:11 PM, Markus Armbruster wrote: >> Zifei Tong writes: >> >>> After commit 812c1057f6175ac9a9829fa2920a2b5783814193 (Handle G_IO_HUP >>> in tcp_chr_read for tcp chardev), connections are disconnected when in >>> G_IO_HUP condition. >>> >>> However, it's possible that there is still data for reading in the channel. >>> In that case, the remaining data is not handled. >>> >>> I saw a related bug when running socat in write-only mode, after >>> >>> $ echo "quit" | socat -u - UNIX-CONNECT:qemu-monitor >>> >>> the monitor won't not run the 'quit' command. >>> >>> Instead of GIOCondition, this patch uses the return value of tcp_chr_recv() >>> to check the state of connection as suggested by Kirill. [...] >>> @@ -2705,7 +2699,7 @@ static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque) >>> if (len > s->max_size) >>> len = s->max_size; >>> size = tcp_chr_recv(chr, (void *)buf, len); >>> - if (size == 0) { >>> + if (size == 0 || (size < 0 && !(errno == EAGAIN || errno == EINTR))) { >>> /* connection closed */ >>> tcp_chr_disconnect(chr); >>> } else if (size > 0) { >> >> What about EWOULDBLOCK? > > I thought EAGAIN and EWOULDBLOCK was the same thing, until Google told > me it's not the case on some platforms like HP-UX, AIX and Tru64. > > Shall we add one more check to support these old platforms? Yes, please! [...]