[Spice-devel] [PATCH] worker: simplify process loops
Frediano Ziglio
fziglio at redhat.com
Tue Jan 26 08:08:39 PST 2016
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 at redhat.com>
---
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
More information about the Spice-devel
mailing list