From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTmpc-0008WA-2E for qemu-devel@nongnu.org; Tue, 16 Sep 2014 03:05:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XTmpW-0007Qe-39 for qemu-devel@nongnu.org; Tue, 16 Sep 2014 03:05:44 -0400 Received: from mail-vc0-x22c.google.com ([2607:f8b0:400c:c03::22c]:56538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTmpV-0007QL-VA for qemu-devel@nongnu.org; Tue, 16 Sep 2014 03:05:38 -0400 Received: by mail-vc0-f172.google.com with SMTP id hy10so4546013vcb.17 for ; Tue, 16 Sep 2014 00:05:34 -0700 (PDT) MIME-Version: 1.0 Sender: soariez@gmail.com In-Reply-To: <874mw8yu8j.fsf@blackfin.pond.sub.org> References: <1410092666-17405-1-git-send-email-zifeitong@gmail.com> <874mw8yu8j.fsf@blackfin.pond.sub.org> From: Zifei Tong Date: Tue, 16 Sep 2014 15:04:54 +0800 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH] qemu-char: Do not disconnect when there's data for reading List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Gerd Hoffmann , Nikolay Nikolaev , qemu-devel@nongnu.org, Anthony Liguori , Kirill Batuzov On Tue, Sep 16, 2014 at 2:06 PM, Markus Armbruster wrote: > Cc'ing Gerd for additional chardev expertise. > > Zifei Tong writes: > >> After commit 812c1057f6175ac9a9829fa2920a2b5783814193 (Handle G_IO_HUP >> in tcp_chr_read for tcp chardev), the connection is disconnected when in >> G_IO_HUP condition. >> >> However, it's possible that the channel is in G_IO_IN condition at the >> same time, meaning there is data for reading. In that case, the >> remaining data is not handled. >> >> I saw a related bug when running socat in write-only mode, with >> >> $ echo "quit" | socat -u - UNIX-CONNECT:qemu-monitor >> >> the monitor won't not run the 'quit' command. > > Reproduced. > > Is this a regression caused by command 812c105? The first bad commit is cdaa86 ("Add G_IO_HUP handler for socket chardev"), which is reverted and reimplemented by 812c105. >> CC: Kirill Batuzov >> CC: Nikolay Nikolaev >> CC: Anthony Liguori >> Signed-off-by: Zifei Tong >> --- >> qemu-char.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/qemu-char.c b/qemu-char.c >> index 1a8d9aa..5018c3a 100644 >> --- a/qemu-char.c >> +++ b/qemu-char.c >> @@ -2706,7 +2706,7 @@ static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque) >> uint8_t buf[READ_BUF_LEN]; >> int len, size; >> >> - if (cond & G_IO_HUP) { >> + if (!(cond & G_IO_IN) && (cond & G_IO_HUP)) { >> /* connection closed */ >> tcp_chr_disconnect(chr); >> return TRUE; > > Kirill, you added the code being changed. Could you review the patch?