Re: [PATCH 07/10] server: make cursor channel private

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

 



On Mon, Nov 02, 2015 at 09:56:03AM +0000, Frediano Ziglio wrote:
> From: Marc-André Lureau <marcandre.lureau@xxxxxxxxx>
> 
> ---
>  server/cursor-channel.c | 24 +++++++++++-
>  server/cursor-channel.h | 18 ++-------
>  server/red_channel.c    | 12 ++++++
>  server/red_channel.h    |  6 +++
>  server/red_worker.c     | 98 ++++++++++++++++++++++---------------------------
>  server/red_worker.h     |  5 +++
>  6 files changed, 92 insertions(+), 71 deletions(-)
> 
> diff --git a/server/cursor-channel.c b/server/cursor-channel.c
> index 6a1fcea..3ae7756 100644
> --- a/server/cursor-channel.c
> +++ b/server/cursor-channel.c
> @@ -19,6 +19,21 @@
>  #include "common/generated_server_marshallers.h"
>  #include "cursor-channel.h"
>  
> +struct CursorChannel {
> +    CommonChannel common; // Must be the first thing
> +
> +    CursorItem *item;
> +    int cursor_visible;
> +    SpicePoint16 cursor_position;
> +    uint16_t cursor_trail_length;
> +    uint16_t cursor_trail_frequency;
> +    uint32_t mouse_mode;
> +
> +#ifdef RED_STATISTICS
> +    StatNodeRef stat;
> +#endif
> +};
> +
>  #define RCC_TO_CCC(rcc) SPICE_CONTAINEROF((rcc), CursorChannelClient, common.base)
>  
>  #define CLIENT_CURSOR_CACHE
> @@ -372,7 +387,7 @@ CursorChannel* cursor_channel_new(RedWorker *worker)
>      };
>  
>      spice_info("create cursor channel");
> -    channel = red_worker_new_channel(worker, sizeof(CursorChannel),
> +    channel = red_worker_new_channel(worker, sizeof(CursorChannel), "cursor_channel",
>                                       SPICE_CHANNEL_CURSOR, 0,
>                                       &cbs, red_channel_client_handle_message);
>  
> @@ -480,3 +495,10 @@ void cursor_channel_reset(CursorChannel *cursor)
>          }
>      }
>  }
> +
> +void cursor_channel_set_mouse_mode(CursorChannel *cursor, uint32_t mode)
> +{
> +    spice_return_if_fail(cursor);
> +
> +    cursor->mouse_mode = mode;
> +}
> diff --git a/server/cursor-channel.h b/server/cursor-channel.h
> index 1639cf9..d5e5b13 100644
> --- a/server/cursor-channel.h
> +++ b/server/cursor-channel.h
> @@ -38,6 +38,8 @@ enum {
>      PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE,
>  };
>  
> +typedef struct CursorChannel CursorChannel;
> +
>  typedef struct CursorItem {
>      QXLInstance *qxl;
>      uint32_t group_id;
> @@ -67,21 +69,6 @@ typedef struct CursorChannelClient {
>      uint32_t cursor_cache_items;
>  } CursorChannelClient;
>  
> -typedef struct CursorChannel {
> -    CommonChannel common; // Must be the first thing
> -
> -    CursorItem *item;
> -    int cursor_visible;
> -    SpicePoint16 cursor_position;
> -    uint16_t cursor_trail_length;
> -    uint16_t cursor_trail_frequency;
> -    uint32_t mouse_mode;
> -
> -#ifdef RED_STATISTICS
> -    StatNodeRef stat;
> -#endif
> -} CursorChannel;
> -
>  G_STATIC_ASSERT(sizeof(CursorItem) <= QXL_CURSUR_DEVICE_DATA_SIZE);
>  
>  CursorChannel*       cursor_channel_new         (RedWorker *worker);
> @@ -89,6 +76,7 @@ void                 cursor_channel_disconnect  (CursorChannel *cursor_channel);
>  void                 cursor_channel_reset       (CursorChannel *cursor);
>  void                 cursor_channel_process_cmd (CursorChannel *cursor, RedCursorCmd *cursor_cmd,
>                                                   uint32_t group_id);
> +void                 cursor_channel_set_mouse_mode(CursorChannel *cursor, uint32_t mode);
>  
>  CursorChannelClient* cursor_channel_client_new(CursorChannel *cursor,
>                                                 RedClient *client, RedsStream *stream,
> diff --git a/server/red_channel.c b/server/red_channel.c
> index 34aa9dc..7330ae2 100644
> --- a/server/red_channel.c
> +++ b/server/red_channel.c
> @@ -1151,9 +1151,21 @@ RedChannel *red_channel_create_parser(int size,
>      }
>      channel->incoming_cb.handle_parsed = (handle_parsed_proc)handle_parsed;
>      channel->incoming_cb.parser = parser;
> +
>      return channel;
>  }
>  
> +void red_channel_set_stat_node(RedChannel *channel, StatNodeRef stat)
> +{
> +    spice_return_if_fail(channel != NULL);
> +    spice_return_if_fail(channel->stat == 0);
> +
> +#ifdef RED_STATISTICS
> +    channel->stat = stat;
> +    channel->out_bytes_counter = stat_add_counter(stat, "out_bytes", TRUE);
> +#endif
> +}
> +
>  void red_channel_register_client_cbs(RedChannel *channel, ClientCbs *client_cbs)
>  {
>      spice_assert(client_cbs->connect || channel->type == SPICE_CHANNEL_MAIN);
> diff --git a/server/red_channel.h b/server/red_channel.h
> index 1f1538e..201a4d2 100644
> --- a/server/red_channel.h
> +++ b/server/red_channel.h
> @@ -32,6 +32,7 @@
>  #include "red_common.h"
>  #include "demarshallers.h"
>  #include "reds_stream.h"
> +#include "stat.h"
>  
>  #define MAX_SEND_BUFS 1000
>  #define CLIENT_ACK_WINDOW 20
> @@ -127,6 +128,7 @@ typedef struct OutgoingHandler {
>  
>  /* Red Channel interface */
>  
> +typedef struct RedsStream RedsStream;
>  typedef struct RedChannel RedChannel;
>  typedef struct RedChannelClient RedChannelClient;
>  typedef struct RedClient RedClient;
> @@ -335,10 +337,13 @@ struct RedChannel {
>      // TODO: when different channel_clients are in different threads from Channel -> need to protect!
>      pthread_t thread_id;
>  #ifdef RED_STATISTICS
> +    StatNodeRef stat;
>      uint64_t *out_bytes_counter;
>  #endif
>  };
>  
> +#define RED_CHANNEL(Channel) ((RedChannel *)(Channel))
> +
>  /*
>   * When an error occurs over a channel, we treat it as a warning
>   * for spice-server and shutdown the channel.
> @@ -370,6 +375,7 @@ RedChannel *red_channel_create_parser(int size,
>                                 channel_handle_parsed_proc handle_parsed,
>                                 ChannelCbs *channel_cbs,
>                                 uint32_t migration_flags);
> +void red_channel_set_stat_node(RedChannel *channel, StatNodeRef stat);
>  
>  void red_channel_register_client_cbs(RedChannel *channel, ClientCbs *client_cbs);
>  // caps are freed when the channel is destroyed
> diff --git a/server/red_worker.c b/server/red_worker.c
> index 868de94..a99da27 100644
> --- a/server/red_worker.c
> +++ b/server/red_worker.c
> @@ -390,7 +390,6 @@ struct DisplayChannel {
>      RedCompressBuf *free_compress_bufs;
>  
>  #ifdef RED_STATISTICS
> -    StatNodeRef stat;
>      uint64_t *cache_hits_counter;
>      uint64_t *add_to_cache_counter;
>      uint64_t *non_cache_counter;
> @@ -1034,8 +1033,8 @@ static int display_is_connected(RedWorker *worker)
>  
>  static int cursor_is_connected(RedWorker *worker)
>  {
> -    return (worker->cursor_channel && red_channel_is_connected(
> -        &worker->cursor_channel->common.base));
> +    return worker->cursor_channel &&
> +        red_channel_is_connected(RED_CHANNEL(worker->cursor_channel));

I think I've already mentioned this before, but introducing these
RED_CHANNEL() macros in a separate patch would make this one much
smaller.

Christophe

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]