From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZwpT-0006uB-Pu for qemu-devel@nongnu.org; Thu, 10 Sep 2015 04:03:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZwpP-0001Jl-Bm for qemu-devel@nongnu.org; Thu, 10 Sep 2015 04:03:35 -0400 Date: Thu, 10 Sep 2015 11:03:25 +0300 From: "Michael S. Tsirkin" Message-ID: <20150910110257-mutt-send-email-mst@redhat.com> References: <1410092666-17405-1-git-send-email-zifeitong@gmail.com> <54227845.6090508@msgid.tls.msk.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54227845.6090508@msgid.tls.msk.ru> Subject: Re: [Qemu-devel] [Qemu-trivial] [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: Michael Tokarev Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org, Nikolay Nikolaev , Kirill Batuzov , Anthony Liguori , Zifei Tong On Wed, Sep 24, 2014 at 11:52:37AM +0400, Michael Tokarev wrote: > 16.09.2014 09:31, Zifei Tong wrote: > > Friendly ping. > > > > Also CC to qemu-trivial. > > There was at least 2 subsequent versions of this down the line, > a v2 and a v3. (Just to show why I haven't applied it to -trivial). > > Thanks, > > /mjt It's also far from trivial. I don't see why it applies there. > > On Sun, Sep 7, 2014 at 8:24 PM, Zifei Tong wrote: > >> 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. > >> > >> 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; > >> -- > >> 2.1.0 > >> > > >