Re: [PATCH 11/20] char-device: Remove RedCharDeviceClass::{un, }ref_msg_to_client

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

 



> 
> From: Christophe Fergeau <cfergeau@xxxxxxxxxx>
> 
> Now that client messages are always RedPipeItem, we don't need virtual
> functions to know how to ref/unref them.
> ---
>  server/char-device.c | 26 ++++----------------------
>  server/char-device.h |  6 ++----
>  server/reds.c        | 14 --------------
>  server/smartcard.c   | 14 --------------
>  server/spicevmc.c    | 16 +---------------
>  5 files changed, 7 insertions(+), 69 deletions(-)
> 
> diff --git a/server/char-device.c b/server/char-device.c
> index ce89d37..ebe7633 100644
> --- a/server/char-device.c
> +++ b/server/char-device.c
> @@ -110,24 +110,6 @@ red_char_device_read_one_msg_from_device(RedCharDevice
> *dev)
>     return klass->read_one_msg_from_device(dev->priv->sin,
>     dev->priv->opaque);
>  }
>  
> -static PipeItem *
> -red_char_device_ref_msg_to_client(RedCharDevice *dev,
> -                                  PipeItem *msg)
> -{
> -   RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> -
> -   return klass->ref_msg_to_client(msg, dev->priv->opaque);
> -}
> -
> -static void
> -red_char_device_unref_msg_to_client(RedCharDevice *dev,
> -                                    PipeItem *msg)
> -{
> -   RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> -
> -   klass->unref_msg_to_client(msg, dev->priv->opaque);
> -}
> -
>  static void
>  red_char_device_send_msg_to_client(RedCharDevice *dev,
>                                     PipeItem *msg,
> @@ -215,7 +197,7 @@ static void
> red_char_device_client_send_queue_free(RedCharDevice *dev,
>                                                                     link);
>  
>          ring_remove(item);
> -        red_char_device_unref_msg_to_client(dev, msg_item->msg);
> +        pipe_item_unref(msg_item->msg);
>          free(msg_item);
>      }
>      dev_client->num_send_tokens += dev_client->send_queue_size;
> @@ -331,7 +313,7 @@ static void
> red_char_device_add_msg_to_client_queue(RedCharDeviceClient *dev_cli
>      }
>  
>      msg_item = spice_new0(RedCharDeviceMsgToClientItem, 1);
> -    msg_item->msg = red_char_device_ref_msg_to_client(dev, msg);
> +    msg_item->msg = pipe_item_ref(msg);
>      ring_add(&dev_client->send_queue, &msg_item->link);
>      dev_client->send_queue_size++;
>      if (!dev_client->wait_for_tokens_started) {
> @@ -401,7 +383,7 @@ static int red_char_device_read_from_device(RedCharDevice
> *dev)
>          }
>          did_read = TRUE;
>          red_char_device_send_msg_to_clients(dev, msg);
> -        red_char_device_unref_msg_to_client(dev, msg);
> +        pipe_item_unref(msg);
>          max_send_tokens--;
>      }
>      dev->priv->during_read_from_device = 0;
> @@ -426,7 +408,7 @@ static void
> red_char_device_client_send_queue_push(RedCharDeviceClient *dev_clie
>          red_char_device_send_msg_to_client(dev_client->dev,
>                                             msg_item->msg,
>                                             dev_client->client);
> -        red_char_device_unref_msg_to_client(dev_client->dev, msg_item->msg);
> +        pipe_item_unref(msg_item->msg);
>          dev_client->send_queue_size--;
>          free(msg_item);
>      }
> diff --git a/server/char-device.h b/server/char-device.h
> index b5a8383..f793c54 100644
> --- a/server/char-device.h
> +++ b/server/char-device.h
> @@ -58,12 +58,10 @@ struct RedCharDeviceClass
>       * or till the reading fails */
>      PipeItem* (*read_one_msg_from_device)(SpiceCharDeviceInstance *sin,
>                                            void *opaque);
> -    PipeItem* (*ref_msg_to_client)(PipeItem *msg, void *opaque);
> -    void (*unref_msg_to_client)(PipeItem *msg, void *opaque);
> -
> +    /* after this call, the message is unreferenced */
>      void (*send_msg_to_client)(PipeItem *msg,
>                                 RedClient *client,
> -                               void *opaque); /* after this call, the
> message is unreferenced */
> +                               void *opaque);
>  
>      /* The cb is called when a predefined number of write buffers were
>      consumed by the
>       * device */
> diff --git a/server/reds.c b/server/reds.c
> index 555b254..6e4fee4 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -855,18 +855,6 @@ static PipeItem
> *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance *sin,
>      return NULL;
>  }
>  
> -static PipeItem *vdi_port_ref_msg_to_client(PipeItem *msg,
> -                                            void *opaque)
> -{
> -    return pipe_item_ref(msg);
> -}
> -
> -static void vdi_port_unref_msg_to_client(PipeItem *msg,
> -                                         void *opaque)
> -{
> -    pipe_item_unref(msg);
> -}
> -
>  /* after calling this, we unref the message, and the ref is in the instance
>  side */
>  static void vdi_port_send_msg_to_client(PipeItem *msg,
>                                          RedClient *client,
> @@ -4331,8 +4319,6 @@
> red_char_device_vdi_port_class_init(RedCharDeviceVDIPortClass *klass)
>      object_class->constructed = red_char_device_vdi_port_constructed;
>  
>      char_dev_class->read_one_msg_from_device =
>      vdi_port_read_one_msg_from_device;
> -    char_dev_class->ref_msg_to_client = vdi_port_ref_msg_to_client;
> -    char_dev_class->unref_msg_to_client = vdi_port_unref_msg_to_client;
>      char_dev_class->send_msg_to_client = vdi_port_send_msg_to_client;
>      char_dev_class->send_tokens_to_client = vdi_port_send_tokens_to_client;
>      char_dev_class->remove_client = vdi_port_remove_client;
> diff --git a/server/smartcard.c b/server/smartcard.c
> index 6bdbef5..b9b8967 100644
> --- a/server/smartcard.c
> +++ b/server/smartcard.c
> @@ -166,18 +166,6 @@ static PipeItem
> *smartcard_read_msg_from_device(SpiceCharDeviceInstance *sin,
>      return NULL;
>  }
>  
> -static PipeItem *smartcard_ref_msg_to_client(PipeItem *msg,
> -                                             void *opaque)
> -{
> -    return pipe_item_ref(msg);
> -}
> -
> -static void smartcard_unref_msg_to_client(PipeItem *msg,
> -                                          void *opaque)
> -{
> -    pipe_item_ref(msg);
> -}
> -
>  static void smartcard_send_msg_to_client(PipeItem *msg,
>                                           RedClient *client,
>                                           void *opaque)
> @@ -857,8 +845,6 @@
> red_char_device_smartcard_class_init(RedCharDeviceSmartcardClass *klass)
>      object_class->finalize = red_char_device_smartcard_finalize;
>  
>      char_dev_class->read_one_msg_from_device =
>      smartcard_read_msg_from_device;
> -    char_dev_class->ref_msg_to_client = smartcard_ref_msg_to_client;
> -    char_dev_class->unref_msg_to_client = smartcard_unref_msg_to_client;
>      char_dev_class->send_msg_to_client = smartcard_send_msg_to_client;
>      char_dev_class->send_tokens_to_client = smartcard_send_tokens_to_client;
>      char_dev_class->remove_client = smartcard_remove_client;
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index 0dcedd1..638f3ef 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -105,20 +105,8 @@ enum {
>      PIPE_ITEM_TYPE_PORT_EVENT,
>  };
>  
> -static PipeItem *spicevmc_chardev_ref_msg_to_client(PipeItem *msg,
> -                                                    void *opaque)
> -{
> -    return pipe_item_ref(msg);
> -}
> -
> -static void spicevmc_chardev_unref_msg_to_client(PipeItem *msg,
> -                                                 void *opaque)
> -{
> -    pipe_item_unref(msg);
> -}
> -
>  static PipeItem *spicevmc_chardev_read_msg_from_dev(SpiceCharDeviceInstance
>  *sin,
> -                                                       void *opaque)
> +                                                    void *opaque)
>  {
>      SpiceVmcState *state = opaque;
>      SpiceCharDeviceInterface *sif;
> @@ -599,8 +587,6 @@
> red_char_device_spicevmc_class_init(RedCharDeviceSpiceVmcClass *klass)
>      RedCharDeviceClass *char_dev_class = RED_CHAR_DEVICE_CLASS(klass);
>  
>      char_dev_class->read_one_msg_from_device =
>      spicevmc_chardev_read_msg_from_dev;
> -    char_dev_class->ref_msg_to_client = spicevmc_chardev_ref_msg_to_client;
> -    char_dev_class->unref_msg_to_client =
> spicevmc_chardev_unref_msg_to_client;
>      char_dev_class->send_msg_to_client =
>      spicevmc_chardev_send_msg_to_client;
>      char_dev_class->send_tokens_to_client =
>      spicevmc_char_dev_send_tokens_to_client;
>      char_dev_class->remove_client = spicevmc_char_dev_remove_client;

Acked-by: Frediano Ziglio <fziglio@xxxxxxxxxx>

Frediano
_______________________________________________
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]