[Spice-commits] 3 commits - server/red-worker.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Thu Jan 28 00:16:47 PST 2016


 server/red-worker.c |   22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

New commits:
commit a61ab509b2be2d6ad72d23d0572cd4d35d986387
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Jan 25 08:21:06 2016 +0000

    worker: remove useless check
    
    display_channel is never NULL.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/red-worker.c b/server/red-worker.c
index 756ea25..eb87813 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -321,8 +321,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
             spice_error("bad command type");
         }
         n++;
-        if ((worker->display_channel &&
-             red_channel_all_blocked(&worker->display_channel->common.base))
+        if (red_channel_all_blocked(&worker->display_channel->common.base)
             || spice_get_monotonic_time_ns() - start > NSEC_PER_SEC / 100) {
             worker->event_timeout = 0;
             return n;
commit 17684522e18ccc64d8ba0ce892049a110524e10a
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Jan 25 08:03:59 2016 +0000

    worker: remove useless test
    
    red_channel_max_pipe_size returns 0 if no client (channel disconnected)
    no need to check if cursor_channel/display_channel are NULL or
    connected.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/red-worker.c b/server/red-worker.c
index fd436a3..756ea25 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -120,12 +120,6 @@ static int display_is_connected(RedWorker *worker)
         &worker->display_channel->common.base));
 }
 
-static int cursor_is_connected(RedWorker *worker)
-{
-    return worker->cursor_channel &&
-        red_channel_is_connected(RED_CHANNEL(worker->cursor_channel));
-}
-
 static uint8_t *common_alloc_recv_buf(RedChannelClient *rcc, uint16_t type, uint32_t size)
 {
     CommonChannel *common = SPICE_CONTAINEROF(rcc->channel, CommonChannel, base);
@@ -177,8 +171,7 @@ static int red_process_cursor(RedWorker *worker, int *ring_is_empty)
     }
 
     *ring_is_empty = FALSE;
-    while (!cursor_is_connected(worker) ||
-           red_channel_max_pipe_size(RED_CHANNEL(worker->cursor_channel)) <= MAX_PIPE_SIZE) {
+    while (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) {
@@ -238,8 +231,7 @@ static int red_process_display(RedWorker *worker, int *ring_is_empty)
 
     worker->process_display_generation++;
     *ring_is_empty = FALSE;
-    while (!display_is_connected(worker) ||
-           red_channel_max_pipe_size(RED_CHANNEL(worker->display_channel)) <= MAX_PIPE_SIZE) {
+    while (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) {
@@ -402,8 +394,7 @@ static void flush_display_commands(RedWorker *worker)
         int sleep_count = 0;
         for (;;) {
             red_channel_push(red_channel);
-            if (!display_is_connected(worker) ||
-                red_channel_max_pipe_size(red_channel) <= MAX_PIPE_SIZE) {
+            if (red_channel_max_pipe_size(red_channel) <= MAX_PIPE_SIZE) {
                 break;
             }
             red_channel_receive(red_channel);
@@ -445,8 +436,7 @@ static void flush_cursor_commands(RedWorker *worker)
         int sleep_count = 0;
         for (;;) {
             red_channel_push(red_channel);
-            if (!cursor_is_connected(worker)
-                || red_channel_max_pipe_size(red_channel) <= MAX_PIPE_SIZE) {
+            if (red_channel_max_pipe_size(red_channel) <= MAX_PIPE_SIZE) {
                 break;
             }
             red_channel_receive(red_channel);
commit 871dbe541782fac31cd097ed5dbceface47ade67
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Jan 25 08:21:44 2016 +0000

    worker: do not leak cursor after disconnecting clients
    
    Calling cursor_channel_disconnect does not free cursor_display
    so this causes a leak.
    Is the only code where this pointer is reset preventing any
    further cursor channel connection. If a client is lazy reading
    cursor data during the flush connection is closed and further clients
    won't be able to use the cursor.
    This also prevents future use of a NULL pointer.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/red-worker.c b/server/red-worker.c
index 6196682..fd436a3 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -454,7 +454,6 @@ static void flush_cursor_commands(RedWorker *worker)
             if (spice_get_monotonic_time_ns() >= end_time) {
                 spice_warning("flush cursor timeout");
                 cursor_channel_disconnect(worker->cursor_channel);
-                worker->cursor_channel = NULL;
             } else {
                 sleep_count++;
                 usleep(DISPLAY_CLIENT_RETRY_INTERVAL);


More information about the Spice-commits mailing list