[Spice-devel] [PATCH 04/19] Remove use of global 'reds' within RedWorker

Frediano Ziglio fziglio at redhat.com
Tue Feb 16 14:32:47 UTC 2016


From: Jonathon Jongsma <jjongsma at redhat.com>

Get the server variable from the RedDispatcher instead of using the
global variable

Acked-by: Fabiano FidĂȘncio <fidencio at redhat.com>
---
 server/display-channel.c |  3 ++-
 server/display-channel.h |  3 ++-
 server/red-worker.c      | 19 ++++++++++++++-----
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index 82dbe03..10faafe 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -2014,7 +2014,8 @@ static SpiceCanvas *image_surfaces_get(SpiceImageSurfaces *surfaces, uint32_t su
     return display->surfaces[surface_id].context.canvas;
 }
 
-DisplayChannel* display_channel_new(RedWorker *worker, int migrate, int stream_video,
+DisplayChannel* display_channel_new(SpiceServer *reds, RedWorker *worker, 
+                                    int migrate, int stream_video,
                                     uint32_t n_surfaces)
 {
     DisplayChannel *display;
diff --git a/server/display-channel.h b/server/display-channel.h
index f2e9f51..cac3b3f 100644
--- a/server/display-channel.h
+++ b/server/display-channel.h
@@ -249,7 +249,8 @@ typedef struct UpgradeItem {
 } UpgradeItem;
 
 
-DisplayChannel*            display_channel_new                       (RedWorker *worker,
+DisplayChannel*            display_channel_new                       (SpiceServer *reds,
+                                                                      RedWorker *worker,
                                                                       int migrate,
                                                                       int stream_video,
                                                                       uint32_t n_surfaces);
diff --git a/server/red-worker.c b/server/red-worker.c
index fe0c05e..2a5963f 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -92,6 +92,8 @@ struct RedWorker {
     FILE *record_fd;
 };
 
+static RedsState* red_worker_get_server(RedWorker *worker);
+
 static int display_is_connected(RedWorker *worker)
 {
     return (worker->display_channel && red_channel_is_connected(
@@ -479,15 +481,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, stat_add_node(reds, worker->stat, name, TRUE));
+    red_channel_set_stat_node(channel, stat_add_node(red_worker_get_server(worker),
+                                                     worker->stat, name, TRUE));
 
     common = (CommonWorkerChannel *)channel;
     common->qxl = worker->qxl;
@@ -1468,6 +1471,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);
 
@@ -1532,7 +1536,7 @@ RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher)
 
     worker->cursor_channel = cursor_channel_new(worker);
     // TODO: handle seemless migration. Temp, setting migrate to FALSE
-    worker->display_channel = display_channel_new(worker, FALSE, reds_get_streaming_video(reds),
+    worker->display_channel = display_channel_new(reds, worker, FALSE, reds_get_streaming_video(reds),
                                                   init_info.n_surfaces);
 
     return worker;
@@ -1592,3 +1596,8 @@ RedChannel* red_worker_get_display_channel(RedWorker *worker)
 
     return RED_CHANNEL(worker->display_channel);
 }
+
+static RedsState* red_worker_get_server(RedWorker *worker)
+{
+    return red_dispatcher_get_server(worker->red_dispatcher);
+}
-- 
2.5.0



More information about the Spice-devel mailing list