]> git.proxmox.com Git - spiceterm.git/commitdiff
only call wakeup when needed
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 8 Oct 2013 09:28:08 +0000 (11:28 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 8 Oct 2013 09:28:08 +0000 (11:28 +0200)
screen.c

index fdbc22149c65c10b37d2130af05d1a5fb4aab463..8d077d1200fc387ad318f050bebc8c70d82342af 100644 (file)
--- a/screen.c
+++ b/screen.c
@@ -118,6 +118,8 @@ simple_set_release_info(QXLReleaseInfo *info, intptr_t ptr)
 static void 
 push_command(SpiceScreen *spice_screen, QXLCommandExt *ext)
 {
+    int need_wakeup = 1;
+
     g_mutex_lock(spice_screen->command_mutex);
 
     while (spice_screen->commands_end - spice_screen->commands_start >= COMMANDS_SIZE) {
@@ -126,12 +128,19 @@ push_command(SpiceScreen *spice_screen, QXLCommandExt *ext)
 
     g_assert(spice_screen->commands_end - spice_screen->commands_start < COMMANDS_SIZE);
 
+    if ((spice_screen->commands_end - spice_screen->commands_start) > 0) {
+        need_wakeup = 0;
+    }
+
     spice_screen->commands[spice_screen->commands_end % COMMANDS_SIZE] = ext;
     spice_screen->commands_end++;
 
+    if (need_wakeup) {
+        spice_screen->qxl_worker->wakeup(spice_screen->qxl_worker);
+    }
+
     g_mutex_unlock(spice_screen->command_mutex);
 
-    spice_screen->qxl_worker->wakeup(spice_screen->qxl_worker);
 }
 
 /* bitmap are freed, so they must be allocated with g_malloc */