Re: [PATCH v2 4/4] channel: use iface parameter to distinguish interface context

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

 



Acked-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>

On Thu, Jan 07, 2016 at 05:32:17PM +0000, Frediano Ziglio wrote:
> Now we can use the iface parameter to distinguish the context instead
> of doing strange assumption on opaque and its state.
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/red-worker.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/server/red-worker.c b/server/red-worker.c
> index b0b7df1..c56b316 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -71,6 +71,7 @@ struct RedWorker {
>      QXLInstance *qxl;
>      RedDispatcher *red_dispatcher;
>      int running;
> +    SpiceCoreInterfaceInternal core;
>      struct pollfd poll_fds[MAX_EVENT_SOURCES];
>      struct SpiceWatch watches[MAX_EVENT_SOURCES];
>      unsigned int event_timeout;
> @@ -534,16 +535,9 @@ static void worker_watch_update_mask(SpiceWatch *watch, int event_mask)
>  static SpiceWatch *worker_watch_add(const SpiceCoreInterfaceInternal *iface,
>                                      int fd, int event_mask, SpiceWatchFunc func, void *opaque)
>  {
> -    /* Since we are a channel core implementation, we always get called from
> -       red_channel_client_create(), so opaque always is our rcc */
> -    RedChannelClient *rcc = opaque;
> -    struct RedWorker *worker;
> +    RedWorker *worker = SPICE_CONTAINEROF(iface, RedWorker, core);
>      int i;
>  
> -    /* Since we are called from red_channel_client_create()
> -       CommonChannelClient->worker has not been set yet! */
> -    worker = SPICE_CONTAINEROF(rcc->channel, CommonChannel, base)->worker;
> -
>      /* Search for a free slot in our poll_fds & watches arrays */
>      for (i = 0; i < MAX_EVENT_SOURCES; i++) {
>          if (worker->poll_fds[i].fd == -1) {
> @@ -551,6 +545,9 @@ static SpiceWatch *worker_watch_add(const SpiceCoreInterfaceInternal *iface,
>          }
>      }
>      if (i == MAX_EVENT_SOURCES) {
> +        /* Since we are a channel core implementation, we always get called from
> +           red_channel_client_create(), so opaque always is our rcc */
> +        RedChannelClient *rcc = opaque;
>          spice_warning("could not add a watch for channel type %u id %u",
>                        rcc->channel->type, rcc->channel->id);
>          return NULL;
> @@ -581,7 +578,7 @@ static void worker_watch_remove(SpiceWatch *watch)
>      memset(watch, 0, sizeof(SpiceWatch));
>  }
>  
> -SpiceCoreInterfaceInternal worker_core = {
> +static const SpiceCoreInterfaceInternal worker_core_initializer = {
>      .timer_add = spice_timer_queue_add,
>      .timer_start = spice_timer_set,
>      .timer_cancel = spice_timer_cancel,
> @@ -641,7 +638,7 @@ CommonChannel *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, &worker_core,
> +    channel = red_channel_create_parser(size, &worker->core,
>                                          channel_type, worker->qxl->id,
>                                          TRUE /* handle_acks */,
>                                          spice_get_client_channel_parser(channel_type, NULL),
> @@ -1546,6 +1543,7 @@ RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher)
>      qxl->st->qif->get_init_info(qxl, &init_info);
>  
>      worker = spice_new0(RedWorker, 1);
> +    worker->core = worker_core_initializer;
>  
>      record_filename = getenv("SPICE_WORKER_RECORD_FILENAME");
>      if (record_filename) {
> -- 
> 2.4.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/spice-devel

Attachment: signature.asc
Description: PGP signature

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