[Spice-devel] [PATCH 10/18] Store reference to RedsState in RedDispatcher

Frediano Ziglio fziglio at redhat.com
Mon Feb 15 16:50:46 UTC 2016


> 
> From: Jonathon Jongsma <jjongsma at redhat.com>
> 
> Remove use of global 'reds' variable from RedDispatcher functions.
> Instead store the owning RedsState variable inside the RedDispatcher
> struct and use that when necessary.

Actually, why not putting the reds pointer into QXLState ?

Frediano

> ---
>  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 c2ca6b6..0fe9164 100644
> --- a/server/red-dispatcher.c
> +++ b/server/red-dispatcher.c
> @@ -56,6 +56,7 @@ struct RedDispatcher {
>      int use_hardware_cursor;
>      QXLDevSurfaceCreate surface_create;
>      unsigned int max_monitors;
> +    RedsState *reds;
>  };
>  
>  static int red_dispatcher_check_qxl_version(RedDispatcher *rd, int major,
>  int minor)
> @@ -327,7 +328,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
> @@ -379,7 +380,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));
>  }
>  
> @@ -902,7 +903,7 @@ void red_dispatcher_async_complete(struct RedDispatcher
> *dispatcher,
>      free(async_command);
>  }
>  
> -void red_dispatcher_init(QXLInstance *qxl)
> +void red_dispatcher_init(RedsState *reds, QXLInstance *qxl)
>  {
>      RedDispatcher *red_dispatcher;
>      RedChannel *channel;
> @@ -919,6 +920,7 @@ void red_dispatcher_init(QXLInstance *qxl)
>      }
>  
>      red_dispatcher = spice_new0(RedDispatcher, 1);
> +    red_dispatcher->reds = reds;
>      red_dispatcher->qxl = qxl;
>      dispatcher_init(&red_dispatcher->dispatcher, RED_WORKER_MESSAGE_COUNT,
>      NULL);
>      red_dispatcher->base.major_version = SPICE_INTERFACE_QXL_MAJOR;
> diff --git a/server/red-dispatcher.h b/server/red-dispatcher.h
> index 1aa63c2..eeb34fa 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);
> +void red_dispatcher_init(SpiceServer *reds, QXLInstance *qxl);
>  
>  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 c30b5a6..80bf9ff 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -3209,7 +3209,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);
> +        red_dispatcher_init(reds, qxl);
>          dispatcher = qxl->st->dispatcher;
>          reds->dispatchers = g_list_prepend(reds->dispatchers, dispatcher);
>  



More information about the Spice-devel mailing list