[PATCH] worker: simplify process loops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It was not clear when req_cmd_notification was called.
This code reproduce just the old behavior but is easier to read.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/red-worker.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/server/red-worker.c b/server/red-worker.c
index 6196682..ea13db5 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -181,17 +181,15 @@ static int red_process_cursor(RedWorker *worker, int *ring_is_empty)
            red_channel_max_pipe_size(RED_CHANNEL(worker->cursor_channel)) <= MAX_PIPE_SIZE) {
         if (!worker->qxl->st->qif->get_cursor_command(worker->qxl, &ext_cmd)) {
             *ring_is_empty = TRUE;
+            if (worker->cursor_poll_tries == CMD_RING_POLL_RETRIES &&
+                !worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
+                continue;
+            }
             if (worker->cursor_poll_tries < CMD_RING_POLL_RETRIES) {
-                worker->cursor_poll_tries++;
                 worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
-                return n;
-            }
-            if (worker->cursor_poll_tries > CMD_RING_POLL_RETRIES ||
-                worker->qxl->st->qif->req_cursor_notification(worker->qxl)) {
-                worker->cursor_poll_tries++;
-                return n;
             }
-            continue;
+            worker->cursor_poll_tries++;
+            return n;
         }
         worker->cursor_poll_tries = 0;
         switch (ext_cmd.cmd.type) {
@@ -242,17 +240,15 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
            red_channel_max_pipe_size(RED_CHANNEL(worker->display_channel)) <= MAX_PIPE_SIZE) {
         if (!worker->qxl->st->qif->get_command(worker->qxl, &ext_cmd)) {
             *ring_is_empty = TRUE;
+            if (worker->display_poll_tries == CMD_RING_POLL_RETRIES &&
+                !worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
+                continue;
+            }
             if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
-                worker->display_poll_tries++;
                 worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
-                return n;
-            }
-            if (worker->display_poll_tries > CMD_RING_POLL_RETRIES ||
-                         worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
-                worker->display_poll_tries++;
-                return n;
             }
-            continue;
+            worker->display_poll_tries++;
+            return n;
         }
 
         if (worker->record_fd)
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]