[Spice-devel] [PATCH 06/13] char-device: Remove RedCharDeviceClass::{un, }ref_msg_to_client

Jonathon Jongsma jjongsma at redhat.com
Wed Apr 13 20:35:30 UTC 2016


Acked-by: Jonathon Jongsma <jjongsma at redhat.com>


On Wed, 2016-04-13 at 14:37 -0500, Jonathon Jongsma wrote:
> From: Christophe Fergeau <cfergeau at redhat.com>
> 
> 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    | 14 --------------
>  5 files changed, 6 insertions(+), 68 deletions(-)
> 
> diff --git a/server/char-device.c b/server/char-device.c
> index 5155cf7..45a485d 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 RedPipeItem *
> -red_char_device_ref_msg_to_client(RedCharDevice *dev,
> -                                  RedPipeItem *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,
> -                                    RedPipeItem *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,
>                                     RedPipeItem *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);
> +        red_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 = red_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);
> +        red_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);
> +        red_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 3bbcd87..d05b1fd 100644
> --- a/server/char-device.h
> +++ b/server/char-device.h
> @@ -58,12 +58,10 @@ struct RedCharDeviceClass
>       * or till the reading fails */
>      RedPipeItem* (*read_one_msg_from_device)(SpiceCharDeviceInstance *sin,
>                                               void *opaque);
> -    RedPipeItem* (*ref_msg_to_client)(RedPipeItem *msg, void *opaque);
> -    void (*unref_msg_to_client)(RedPipeItem *msg, void *opaque);
> -
> +    /* after this call, the message is unreferenced */
>      void (*send_msg_to_client)(RedPipeItem *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 37879ed..5514e05 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -855,18 +855,6 @@ static RedPipeItem
> *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance *s
>      return NULL;
>  }
>  
> -static RedPipeItem *vdi_port_ref_msg_to_client(RedPipeItem *msg,
> -                                               void *opaque)
> -{
> -    return red_pipe_item_ref(msg);
> -}
> -
> -static void vdi_port_unref_msg_to_client(RedPipeItem *msg,
> -                                         void *opaque)
> -{
> -    red_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(RedPipeItem *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 4149904..4207af8 100644
> --- a/server/smartcard.c
> +++ b/server/smartcard.c
> @@ -167,18 +167,6 @@ static RedPipeItem
> *smartcard_read_msg_from_device(SpiceCharDeviceInstance *sin,
>      return NULL;
>  }
>  
> -static RedPipeItem *smartcard_ref_msg_to_client(RedPipeItem *msg,
> -                                                void *opaque)
> -{
> -    return red_pipe_item_ref(msg);
> -}
> -
> -static void smartcard_unref_msg_to_client(RedPipeItem *msg,
> -                                          void *opaque)
> -{
> -    red_pipe_item_ref(msg);
> -}
> -
>  static void smartcard_send_msg_to_client(RedPipeItem *msg,
>                                           RedClient *client,
>                                           void *opaque)
> @@ -858,8 +846,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 65990d6..1015588 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -105,18 +105,6 @@ enum {
>      PIPE_ITEM_TYPE_PORT_EVENT,
>  };
>  
> -static RedPipeItem *spicevmc_chardev_ref_msg_to_client(RedPipeItem *msg,
> -                                                       void *opaque)
> -{
> -    return red_pipe_item_ref(msg);
> -}
> -
> -static void spicevmc_chardev_unref_msg_to_client(RedPipeItem *msg,
> -                                                 void *opaque)
> -{
> -    red_pipe_item_unref(msg);
> -}
> -
>  static RedPipeItem
> *spicevmc_chardev_read_msg_from_dev(SpiceCharDeviceInstance *sin,
>                                                         void *opaque)
>  {
> @@ -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;


More information about the Spice-devel mailing list