[Spice-devel] [PATCH 11/17] Remove use of global 'reds' within RedWorker

Frediano Ziglio fziglio at redhat.com
Thu Feb 11 19:24:10 UTC 2016


From: Jonathon Jongsma <jjongsma at redhat.com>

Get the server variable from the RedDispatcher instead of using the
global variable
---
 server/display-channel.c |  1 +
 server/red-worker.c      | 15 +++++++++++----
 server/red-worker.h      |  1 +
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index c46676d..79e4cc0 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2032,6 +2032,7 @@ DisplayChannel* display_channel_new(RedWorker *worker, int migrate, int stream_v
     static SpiceImageSurfacesOps image_surfaces_ops = {
         image_surfaces_get,
     };
+    RedsState *reds = red_worker_get_server(worker);
 
     spice_info("create display channel");
     display = (DisplayChannel *)red_worker_new_channel(
diff --git a/server/red-worker.c b/server/red-worker.c
index 03d05dd..4265e10 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -513,15 +513,16 @@ CommonWorkerChannel *red_worker_new_channel(RedWorker *worker, int size,
     channel_cbs->alloc_recv_buf = common_alloc_recv_buf;
     channel_cbs->release_recv_buf = common_release_recv_buf;
 
-    channel = red_channel_create_parser(size, reds, &worker->core,
-                                        channel_type, worker->qxl->id,
-                                        TRUE /* handle_acks */,
+    channel = red_channel_create_parser(size, red_worker_get_server(worker),
+                                        &worker->core, channel_type,
+                                        worker->qxl->id, TRUE /* handle_acks */,
                                         spice_get_client_channel_parser(channel_type, NULL),
                                         handle_parsed,
                                         channel_cbs,
                                         migration_flags);
     spice_return_val_if_fail(channel, NULL);
-    red_channel_set_stat_node(channel, reds_stat_add_node(reds, worker->stat, name, TRUE));
+    red_channel_set_stat_node(channel, reds_stat_add_node(red_worker_get_server(worker),
+                                                          worker->stat, name, TRUE));
 
     common = (CommonWorkerChannel *)channel;
     common->worker = worker;
@@ -1505,6 +1506,7 @@ RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher)
     RedWorker *worker;
     Dispatcher *dispatcher;
     const char *record_filename;
+    RedsState *reds = red_dispatcher_get_server(red_dispatcher);
 
     qxl->st->qif->get_init_info(qxl, &init_info);
 
@@ -1629,3 +1631,8 @@ RedChannel* red_worker_get_display_channel(RedWorker *worker)
 
     return RED_CHANNEL(worker->display_channel);
 }
+
+RedsState* red_worker_get_server(RedWorker *worker)
+{
+    return red_dispatcher_get_server(worker->red_dispatcher);
+}
diff --git a/server/red-worker.h b/server/red-worker.h
index 8e499a1..e9f5291 100644
--- a/server/red-worker.h
+++ b/server/red-worker.h
@@ -98,6 +98,7 @@ QXLInstance* red_worker_get_qxl(RedWorker *worker);
 RedChannel* red_worker_get_cursor_channel(RedWorker *worker);
 RedChannel* red_worker_get_display_channel(RedWorker *worker);
 RedMemSlotInfo* red_worker_get_memslot(RedWorker *worker);
+RedsState* red_worker_get_server(RedWorker *worker);
 
 void red_drawable_unref(RedWorker *worker, RedDrawable *red_drawable,
                         uint32_t group_id);
-- 
2.5.0



More information about the Spice-devel mailing list