[Spice-devel] [PATCH 5/9] server: dispatcher_init/dispatcher_new

Frediano Ziglio fziglio at redhat.com
Wed Oct 21 05:37:25 PDT 2015


> 
> From: Marc-André Lureau <marcandre.lureau at gmail.com>
> 
> ---
>  server/red_dispatcher.c | 6 ++++--
>  server/red_dispatcher.h | 2 +-
>  server/reds.c           | 2 +-
>  3 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
> index 0bc853d..c43da7d 100644
> --- a/server/red_dispatcher.c
> +++ b/server/red_dispatcher.c
> @@ -1060,7 +1060,7 @@ static RedChannel
> *red_dispatcher_cursor_channel_create(RedDispatcher *dispatche
>      return cursor_channel;
>  }
>  
> -void red_dispatcher_init(QXLInstance *qxl)
> +RedDispatcher *red_dispatcher_new(QXLInstance *qxl)
>  {
>      RedDispatcher *red_dispatcher;
>      WorkerInitData init_data;
> @@ -1069,7 +1069,7 @@ void red_dispatcher_init(QXLInstance *qxl)
>      RedChannel *cursor_channel;
>      ClientCbs client_cbs = { NULL, };
>  
> -    spice_return_if_fail(qxl->st->dispatcher == NULL);
> +    spice_return_val_if_fail(qxl->st->dispatcher == NULL, NULL);
> 

This is just going to leak the old dispatcher if already set, see below.
This should be an assert.
 
>      static gsize initialized = FALSE;
>      if (g_once_init_enter(&initialized)) {
> @@ -1164,6 +1164,8 @@ void red_dispatcher_init(QXLInstance *qxl)
>  
>      qxl->st->qif->attache_worker(qxl, &red_dispatcher->base);
>      qxl->st->qif->set_compression_level(qxl, calc_compression_level());
> +
> +    return red_dispatcher;
>  }
>  
>  struct Dispatcher *red_dispatcher_get_dispatcher(RedDispatcher
>  *red_dispatcher)
> diff --git a/server/red_dispatcher.h b/server/red_dispatcher.h
> index ae46982..f487317 100644
> --- a/server/red_dispatcher.h
> +++ b/server/red_dispatcher.h
> @@ -28,7 +28,7 @@ typedef struct RedChannelClient RedChannelClient;
>  
>  typedef struct AsyncCommand AsyncCommand;
>  
> -void red_dispatcher_init(QXLInstance *qxl);
> +RedDispatcher *red_dispatcher_new(QXLInstance *qxl);
>  
>  void red_dispatcher_set_mm_time(uint32_t);
>  void red_dispatcher_on_ic_change(void);
> diff --git a/server/reds.c b/server/reds.c
> index 2aea688..d53ea66 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -3156,7 +3156,7 @@ SPICE_GNUC_VISIBLE int
> spice_server_add_interface(SpiceServer *s,
>          qxl = SPICE_CONTAINEROF(sin, QXLInstance, base);
>          qxl->st = spice_new0(QXLState, 1);
>          qxl->st->qif = SPICE_CONTAINEROF(interface, QXLInterface, base);
> -        red_dispatcher_init(qxl);
> +        qxl->st->dispatcher = red_dispatcher_new(qxl);
>

Here the NULL is set.
  
>      } else if (strcmp(interface->type, SPICE_INTERFACE_TABLET) == 0) {
>          spice_info("SPICE_INTERFACE_TABLET");

The rename make sense.

Frediano


More information about the Spice-devel mailing list