[PATCH 09/17] Store reference to RedsState in RedDispatcher

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

 



From: Jonathon Jongsma <jjongsma@xxxxxxxxxx>

Remove use of global 'reds' variable from RedDispatcher functions.
Instead store the owning RedsState variable inside the RedDispatcher
struct and use that when necessary.
---
 server/red-dispatcher.c | 8 +++++---
 server/red-dispatcher.h | 2 +-
 server/reds.c           | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/server/red-dispatcher.c b/server/red-dispatcher.c
index ead598d..26811e7 100644
--- a/server/red-dispatcher.c
+++ b/server/red-dispatcher.c
@@ -59,6 +59,7 @@ struct RedDispatcher {
     pthread_mutex_t  async_lock;
     QXLDevSurfaceCreate surface_create;
     unsigned int max_monitors;
+    RedsState *reds;
 };
 
 static int red_dispatcher_check_qxl_version(RedDispatcher *rd, int major, int minor)
@@ -333,7 +334,7 @@ static void red_dispatcher_destroy_primary_surface_complete(RedDispatcher *dispa
     dispatcher->use_hardware_cursor = FALSE;
     dispatcher->primary_active = FALSE;
 
-    reds_update_client_mouse_allowed(reds);
+    reds_update_client_mouse_allowed(dispatcher->reds);
 }
 
 static void
@@ -385,7 +386,7 @@ static void red_dispatcher_create_primary_surface_complete(RedDispatcher *dispat
     dispatcher->use_hardware_cursor = surface->mouse_mode;
     dispatcher->primary_active = TRUE;
 
-    reds_update_client_mouse_allowed(reds);
+    reds_update_client_mouse_allowed(dispatcher->reds);
     memset(&dispatcher->surface_create, 0, sizeof(QXLDevSurfaceCreate));
 }
 
@@ -908,7 +909,7 @@ void red_dispatcher_async_complete(struct RedDispatcher *dispatcher,
     free(async_command);
 }
 
-void red_dispatcher_init(QXLInstance *qxl, int compression_level)
+void red_dispatcher_init(RedsState *reds, QXLInstance *qxl, int compression_level)
 {
     RedDispatcher *red_dispatcher;
     RedChannel *channel;
@@ -925,6 +926,7 @@ void red_dispatcher_init(QXLInstance *qxl, int compression_level)
     }
 
     red_dispatcher = spice_new0(RedDispatcher, 1);
+    red_dispatcher->reds = reds;
     red_dispatcher->qxl = qxl;
     ring_init(&red_dispatcher->async_commands);
     spice_debug("red_dispatcher->async_commands.next %p", red_dispatcher->async_commands.next);
diff --git a/server/red-dispatcher.h b/server/red-dispatcher.h
index e62092f..887123f 100644
--- a/server/red-dispatcher.h
+++ b/server/red-dispatcher.h
@@ -24,7 +24,7 @@ typedef struct RedDispatcher RedDispatcher;
 
 typedef struct AsyncCommand AsyncCommand;
 
-void red_dispatcher_init(QXLInstance *qxl, int compression_level);
+void red_dispatcher_init(RedsState *reds, QXLInstance *qxl, int compression_level);
 
 void red_dispatcher_set_mm_time(RedDispatcher *dispatcher, uint32_t);
 void red_dispatcher_on_ic_change(RedDispatcher *dispatcher, SpiceImageCompression ic);
diff --git a/server/reds.c b/server/reds.c
index eec8086..4611c97 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3208,7 +3208,7 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
         pthread_mutex_init(&qxl->st->scanout_mutex, NULL);
         qxl->st->scanout.drm_dma_buf_fd = -1;
         qxl->st->qif = SPICE_CONTAINEROF(interface, QXLInterface, base);
-        red_dispatcher_init(qxl, calc_compression_level(reds));
+        red_dispatcher_init(reds, qxl, calc_compression_level(reds));
         reds->dispatchers = g_list_prepend(reds->dispatchers, qxl->st->dispatcher);
 
     } else if (strcmp(interface->type, SPICE_INTERFACE_TABLET) == 0) {
-- 
2.5.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://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]