[Spice-devel] [PATCH v2 9/9] replay: do not wake up loop too much

Frediano Ziglio fziglio at redhat.com
Tue Jan 26 01:44:36 PST 2016


Send wakeups only when a command is available.
This emulate better what a guest driver should do (append the command
to the ring and then signal).

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/tests/replay.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/server/tests/replay.c b/server/tests/replay.c
index 0c98168..517b8fd 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -26,6 +26,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <stdbool.h>
 #include <sys/types.h>
 #include <signal.h>
 #include <unistd.h>
@@ -108,6 +109,7 @@ static void get_init_info(QXLInstance *qin, QXLDevInitInfo *info)
 static gboolean fill_queue_idle(gpointer user_data)
 {
     gboolean keep = FALSE;
+    bool wakeup = false;
 
     while (g_async_queue_length(aqueue) < 50) {
         QXLCommandExt *cmd = spice_replay_next_cmd(replay, qxl_worker);
@@ -119,6 +121,7 @@ static gboolean fill_queue_idle(gpointer user_data)
         if (slow)
             g_usleep(slow);
 
+        wakeup = true;
         g_async_queue_push(aqueue, cmd);
     }
 
@@ -132,7 +135,8 @@ end:
         }
         pthread_mutex_unlock(&mutex);
     }
-    spice_qxl_wakeup(&display_sin);
+    if (wakeup)
+        spice_qxl_wakeup(&display_sin);
 
     return keep;
 }
-- 
2.4.3



More information about the Spice-devel mailing list