9ae3a8
From 67517d9d08977cf80a2528502b9de5351c17c990 Mon Sep 17 00:00:00 2001
9ae3a8
From: "Daniel P. Berrange" <berrange@redhat.com>
9ae3a8
Date: Thu, 8 Feb 2018 17:50:17 +0100
9ae3a8
Subject: [PATCH 03/27] vnc update fix
9ae3a8
9ae3a8
RH-Author: Daniel P. Berrange <berrange@redhat.com>
9ae3a8
Message-id: <20180208175041.5634-4-berrange@redhat.com>
9ae3a8
Patchwork-id: 78942
9ae3a8
O-Subject: [RHEL-7.5 qemu-kvm PATCH v1 03/27] vnc update fix
9ae3a8
Bugzilla: 1527405
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
From: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
9ae3a8
We need to remember has_updates for each vnc client.  Otherwise it might
9ae3a8
happen that vnc_update_client(has_dirty=1) takes the first exit due to
9ae3a8
output buffers not being flushed yet and subsequent calls with
9ae3a8
has_dirty=0 take the second exit, wrongly assuming there is nothing to
9ae3a8
do because the work defered in the first call is ignored.
9ae3a8
9ae3a8
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
9ae3a8
Reviewed-by: Peter Lieven <pl@kamp.de>
9ae3a8
(cherry picked from commit 6365828003c8e88bff67d351af4b66c406568a26)
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 ui/vnc.c | 4 +++-
9ae3a8
 ui/vnc.h | 1 +
9ae3a8
 2 files changed, 4 insertions(+), 1 deletion(-)
9ae3a8
9ae3a8
diff --git a/ui/vnc.c b/ui/vnc.c
9ae3a8
index 5226295..42070b4 100644
9ae3a8
--- a/ui/vnc.c
9ae3a8
+++ b/ui/vnc.c
9ae3a8
@@ -794,6 +794,7 @@ static int find_and_clear_dirty_height(struct VncState *vs,
9ae3a8
 
9ae3a8
 static int vnc_update_client(VncState *vs, int has_dirty)
9ae3a8
 {
9ae3a8
+    vs->has_dirty += has_dirty;
9ae3a8
     if (vs->need_update && vs->csock != -1) {
9ae3a8
         VncDisplay *vd = vs->vd;
9ae3a8
         VncJob *job;
9ae3a8
@@ -805,7 +806,7 @@ static int vnc_update_client(VncState *vs, int has_dirty)
9ae3a8
             /* kernel send buffers are full -> drop frames to throttle */
9ae3a8
             return 0;
9ae3a8
 
9ae3a8
-        if (!has_dirty && !vs->audio_cap && !vs->force_update)
9ae3a8
+        if (!vs->has_dirty && !vs->audio_cap && !vs->force_update)
9ae3a8
             return 0;
9ae3a8
 
9ae3a8
         /*
9ae3a8
@@ -845,6 +846,7 @@ static int vnc_update_client(VncState *vs, int has_dirty)
9ae3a8
 
9ae3a8
         vnc_job_push(job);
9ae3a8
         vs->force_update = 0;
9ae3a8
+        vs->has_dirty = 0;
9ae3a8
         return n;
9ae3a8
     }
9ae3a8
 
9ae3a8
diff --git a/ui/vnc.h b/ui/vnc.h
9ae3a8
index 8d534b6..d1badbb 100644
9ae3a8
--- a/ui/vnc.h
9ae3a8
+++ b/ui/vnc.h
9ae3a8
@@ -263,6 +263,7 @@ struct VncState
9ae3a8
     VncDisplay *vd;
9ae3a8
     int need_update;
9ae3a8
     int force_update;
9ae3a8
+    int has_dirty;
9ae3a8
     uint32_t features;
9ae3a8
     int absolute;
9ae3a8
     int last_x;
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8