Blame SOURCES/kvm-ui-Always-remove-an-old-VNC-channel-watch-before-add.patch

4a2fec
From 2c959596e23736aadad5010a8db665b99359b517 Mon Sep 17 00:00:00 2001
4a2fec
From: "Daniel P. Berrange" <berrange@redhat.com>
4a2fec
Date: Wed, 20 Dec 2017 17:56:46 +0100
4a2fec
Subject: [PATCH 06/42] ui: Always remove an old VNC channel watch before
4a2fec
 adding a new one
4a2fec
4a2fec
RH-Author: Daniel P. Berrange <berrange@redhat.com>
4a2fec
Message-id: <20171220175702.29663-5-berrange@redhat.com>
4a2fec
Patchwork-id: 78457
4a2fec
O-Subject: [RHV-7.5 qemu-kvm-rhev PATCH v2 04/20] ui: Always remove an old VNC channel watch before adding a new one
4a2fec
Bugzilla: 1518649
4a2fec
RH-Acked-by: John Snow <jsnow@redhat.com>
4a2fec
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
4a2fec
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
4a2fec
From: Brandon Carpenter <brandon.carpenter@cypherpath.com>
4a2fec
4a2fec
Also set saved handle to zero when removing without adding a new watch.
4a2fec
4a2fec
Signed-off-by: Brandon Carpenter <brandon.carpenter@cypherpath.com>
4a2fec
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
4a2fec
(cherry picked from commit a75d6f07613af7ec5b016b31b117436e32ce7a5f)
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 ui/vnc-auth-vencrypt.c | 3 +++
4a2fec
 ui/vnc-ws.c            | 6 ++++++
4a2fec
 ui/vnc.c               | 4 ++++
4a2fec
 3 files changed, 13 insertions(+)
4a2fec
4a2fec
diff --git a/ui/vnc-auth-vencrypt.c b/ui/vnc-auth-vencrypt.c
4a2fec
index ffaab57..c3eece4 100644
4a2fec
--- a/ui/vnc-auth-vencrypt.c
4a2fec
+++ b/ui/vnc-auth-vencrypt.c
4a2fec
@@ -77,6 +77,9 @@ static void vnc_tls_handshake_done(QIOTask *task,
4a2fec
         vnc_client_error(vs);
4a2fec
         error_free(err);
4a2fec
     } else {
4a2fec
+        if (vs->ioc_tag) {
4a2fec
+            g_source_remove(vs->ioc_tag);
4a2fec
+        }
4a2fec
         vs->ioc_tag = qio_channel_add_watch(
4a2fec
             vs->ioc, G_IO_IN | G_IO_OUT, vnc_client_io, vs, NULL);
4a2fec
         start_auth_vencrypt_subauth(vs);
4a2fec
diff --git a/ui/vnc-ws.c b/ui/vnc-ws.c
4a2fec
index f530cd5..eaf3095 100644
4a2fec
--- a/ui/vnc-ws.c
4a2fec
+++ b/ui/vnc-ws.c
4a2fec
@@ -36,6 +36,9 @@ static void vncws_tls_handshake_done(QIOTask *task,
4a2fec
         error_free(err);
4a2fec
     } else {
4a2fec
         VNC_DEBUG("TLS handshake complete, starting websocket handshake\n");
4a2fec
+        if (vs->ioc_tag) {
4a2fec
+            g_source_remove(vs->ioc_tag);
4a2fec
+        }
4a2fec
         vs->ioc_tag = qio_channel_add_watch(
4a2fec
             QIO_CHANNEL(vs->ioc), G_IO_IN, vncws_handshake_io, vs, NULL);
4a2fec
     }
4a2fec
@@ -97,6 +100,9 @@ static void vncws_handshake_done(QIOTask *task,
4a2fec
     } else {
4a2fec
         VNC_DEBUG("Websock handshake complete, starting VNC protocol\n");
4a2fec
         vnc_start_protocol(vs);
4a2fec
+        if (vs->ioc_tag) {
4a2fec
+            g_source_remove(vs->ioc_tag);
4a2fec
+        }
4a2fec
         vs->ioc_tag = qio_channel_add_watch(
4a2fec
             vs->ioc, G_IO_IN, vnc_client_io, vs, NULL);
4a2fec
     }
4a2fec
diff --git a/ui/vnc.c b/ui/vnc.c
4a2fec
index 5b1e264..4e1d94f 100644
4a2fec
--- a/ui/vnc.c
4a2fec
+++ b/ui/vnc.c
4a2fec
@@ -1121,6 +1121,7 @@ static void vnc_disconnect_start(VncState *vs)
4a2fec
     vnc_set_share_mode(vs, VNC_SHARE_MODE_DISCONNECTED);
4a2fec
     if (vs->ioc_tag) {
4a2fec
         g_source_remove(vs->ioc_tag);
4a2fec
+        vs->ioc_tag = 0;
4a2fec
     }
4a2fec
     qio_channel_close(vs->ioc, NULL);
4a2fec
     vs->disconnecting = TRUE;
4a2fec
@@ -2931,6 +2932,9 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSocket *sioc,
4a2fec
     VNC_DEBUG("New client on socket %p\n", vs->sioc);
4a2fec
     update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE);
4a2fec
     qio_channel_set_blocking(vs->ioc, false, NULL);
4a2fec
+    if (vs->ioc_tag) {
4a2fec
+        g_source_remove(vs->ioc_tag);
4a2fec
+    }
4a2fec
     if (websocket) {
4a2fec
         vs->websocket = 1;
4a2fec
         if (vd->tlscreds) {
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec