All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-char: Do not disconnect when there's data for reading
@ 2014-09-07 12:24 Zifei Tong
  2014-09-16  5:31 ` Zifei Tong
  2014-09-16  6:06 ` [Qemu-devel] " Markus Armbruster
  0 siblings, 2 replies; 8+ messages in thread
From: Zifei Tong @ 2014-09-07 12:24 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kirill Batuzov, Anthony Liguori, Nikolay Nikolaev, Zifei Tong

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 <batuzovk@ispras.ru>
CC: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
CC: Anthony Liguori <aliguori@amazon.com>
Signed-off-by: Zifei Tong <zifeitong@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-09-10  8:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-07 12:24 [Qemu-devel] [PATCH] qemu-char: Do not disconnect when there's data for reading Zifei Tong
2014-09-16  5:31 ` Zifei Tong
2014-09-24  7:52   ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2015-09-10  8:03     ` Michael S. Tsirkin
2014-09-16  6:06 ` [Qemu-devel] " Markus Armbruster
2014-09-16  7:04   ` Zifei Tong
2014-09-16 15:30   ` Kirill Batuzov
2014-09-17 10:44     ` Zifei Tong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.