summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorPeter Lieven <pl@kamp.de>2015-10-30 12:10:11 +0100
committerGerd Hoffmann <kraxel@redhat.com>2015-11-05 09:09:31 +0100
commitc3d6899c5e67dfd7ff195eccc10541f3b7e141a7 (patch)
treea1564cd0a9d2f84534015461af4ec32e43d3a0ab /ui
parent2e0c90af0a33451498d333d72c06e5429c7cd168 (diff)
downloadhqemu-c3d6899c5e67dfd7ff195eccc10541f3b7e141a7.zip
hqemu-c3d6899c5e67dfd7ff195eccc10541f3b7e141a7.tar.gz
vnc: recycle empty vs->output buffer
If the vs->output buffer is empty it will be dropped by the next qio_buffer_move_empty in vnc_jobs_consume_buffer anyway. So reuse the allocated buffer from this buffer in the worker thread where we otherwise would start with an empty (unallocated buffer). Signed-off-by: Peter Lieven <pl@kamp.de> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 1446203414-4013-17-git-send-email-kraxel@redhat.com [ added a comment describing the non-obvious optimization ] Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/vnc-jobs.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c
index 12389cc..08f0163 100644
--- a/ui/vnc-jobs.c
+++ b/ui/vnc-jobs.c
@@ -235,6 +235,14 @@ static int vnc_worker_thread_loop(VncJobQueue *queue)
vnc_unlock_output(job->vs);
goto disconnected;
}
+ if (buffer_empty(&job->vs->output)) {
+ /*
+ * Looks like a NOP as it obviously moves no data. But it
+ * moves the empty buffer, so we don't have to malloc a new
+ * one for vs.output
+ */
+ buffer_move_empty(&vs.output, &job->vs->output);
+ }
vnc_unlock_output(job->vs);
/* Make a local copy of vs and switch output buffers */
OpenPOWER on IntegriCloud