Skip to contentSkip to conversation

chardev-socket: do not blindly reset handlers when switching GMainContext

PATCH New Paolo Bonzini 1 participant 1 message Feb 20, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 chardev-socket: do not blindly reset handlers when switching GMainContext

If the socket is connecting or connected, tcp_chr_update_read_handler will be called but it should not set the NetListener's callbacks again. Otherwise, tcp_chr_accept is invoked while the socket is in connected state and you get an assertion failure.

---
 chardev/char-socket.c |  2 +-
 tests/test-char.c     | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 95 insertions(+), 2 deletions(-)
chardev/char-socket.c +1 -1
index 4fcdd8a..6d287ba 100644
@@ -632,7 +632,7 @@ static void tcp_chr_update_read_handler(Chardev *chr)
 {
     SocketChardev *s = SOCKET_CHARDEV(chr);
 
-    if (s->listener) {
+    if (s->listener && s->state == TCP_CHARDEV_STATE_DISCONNECTED) {
         /*
          * It's possible that chardev context is changed in
          * qemu_chr_be_update_read_handlers().  Reset it for QIO net
tests/test-char.c +94 -1

107 lines not on this page · raw message

Signature · 1 line
1.8.3.1