[Spice-devel] [PATCH 5/9] move is_low_bandwidth to DisplayChannelClient

Jonathon Jongsma jjongsma at redhat.com
Fri Aug 5 20:48:46 UTC 2016


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


On Thu, 2016-08-04 at 16:17 -0500, Jonathon Jongsma wrote:
> From: Frediano Ziglio <fziglio at redhat.com>
> 
> The field is only used by DisplayChannelClient, not by
> CursorChannelClient
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/dcc-private.h     |  1 +
>  server/dcc-send.c        |  2 +-
>  server/dcc.c             | 17 ++++++++++++++++-
>  server/dcc.h             |  2 ++
>  server/display-channel.c |  7 ++++---
>  server/red-worker.c      | 14 +++++++-------
>  server/red-worker.h      |  5 ++---
>  server/stream.c          |  4 ++--
>  8 files changed, 35 insertions(+), 17 deletions(-)
> 
> diff --git a/server/dcc-private.h b/server/dcc-private.h
> index 6e11163..dbe88aa 100644
> --- a/server/dcc-private.h
> +++ b/server/dcc-private.h
> @@ -25,6 +25,7 @@
>  
>  struct DisplayChannelClient {
>      CommonGraphicsChannelClient common;
> +    int is_low_bandwidth;
>      uint32_t id;
>      SpiceImageCompression image_compression;
>      spice_wan_compression_t jpeg_state;
> diff --git a/server/dcc-send.c b/server/dcc-send.c
> index 395129f..406907b 100644
> --- a/server/dcc-send.c
> +++ b/server/dcc-send.c
> @@ -1845,7 +1845,7 @@ static void
> display_channel_marshall_migrate_data(RedChannelClient *rcc,
>                   MIGRATE_DATA_DISPLAY_MAX_CACHE_CLIENTS ==
> MAX_CACHE_CLIENTS);
>  
>      display_data.message_serial =
> red_channel_client_get_message_serial(rcc);
> -    display_data.low_bandwidth_setting = dcc-
> >common.is_low_bandwidth;
> +    display_data.low_bandwidth_setting = dcc->is_low_bandwidth;
>  
>      display_data.pixmap_cache_freezer = pixmap_cache_freeze(dcc-
> >pixmap_cache);
>      display_data.pixmap_cache_id = dcc->pixmap_cache->id;
> diff --git a/server/dcc.c b/server/dcc.c
> index 24d3d4b..fe9551e 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -1107,7 +1107,7 @@ int
> dcc_handle_migrate_data(DisplayChannelClient *dcc, uint32_t size,
> void *mess
>          spice_critical("restoring global lz dictionary failed");
>      }
>  
> -    dcc->common.is_low_bandwidth = migrate_data-
> >low_bandwidth_setting;
> +    dcc->is_low_bandwidth = migrate_data->low_bandwidth_setting;
>  
>      if (migrate_data->low_bandwidth_setting) {
>          red_channel_client_ack_set_client_window(RED_CHANNEL_CLIENT(
> dcc), WIDE_CLIENT_ACK_WINDOW);
> @@ -1176,3 +1176,18 @@ void
> dcc_set_max_stream_bit_rate(DisplayChannelClient *dcc, uint64_t rate)
>  {
>      dcc->streams_max_bit_rate = rate;
>  }
> +
> +int dcc_config_socket(RedChannelClient *rcc)
> +{
> +    RedClient *client = red_channel_client_get_client(rcc);
> +    MainChannelClient *mcc = red_client_get_main(client);
> +
> +    RCC_TO_DCC(rcc)->is_low_bandwidth =
> main_channel_client_is_low_bandwidth(mcc);
> +
> +    return common_channel_config_socket(rcc);
> +}
> +
> +gboolean dcc_is_low_bandwidth(DisplayChannelClient *dcc)
> +{
> +    return dcc->is_low_bandwidth;
> +}
> diff --git a/server/dcc.h b/server/dcc.h
> index 4d9dccb..1fc9fa7 100644
> --- a/server/dcc.h
> +++ b/server/dcc.h
> @@ -172,5 +172,7 @@ uint32_t
> dcc_get_max_stream_latency(DisplayChannelClient *dcc);
>  void dcc_set_max_stream_latency(DisplayChannelClient *dcc, uint32_t
> latency);
>  uint64_t dcc_get_max_stream_bit_rate(DisplayChannelClient *dcc);
>  void dcc_set_max_stream_bit_rate(DisplayChannelClient *dcc, uint64_t
> rate);
> +int dcc_config_socket(RedChannelClient *rcc);
> +gboolean dcc_is_low_bandwidth(DisplayChannelClient *dcc);
>  
>  #endif /* DCC_H_ */
> diff --git a/server/display-channel.c b/server/display-channel.c
> index 89bb0c6..555bae2 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -1897,7 +1897,8 @@ DisplayChannel* display_channel_new(SpiceServer
> *reds, RedWorker *worker,
>          .send_item = dcc_send_item,
>          .handle_migrate_flush_mark = handle_migrate_flush_mark,
>          .handle_migrate_data = handle_migrate_data,
> -        .handle_migrate_data_get_serial =
> handle_migrate_data_get_serial
> +        .handle_migrate_data_get_serial =
> handle_migrate_data_get_serial,
> +        .config_socket = dcc_config_socket
>      };
>      static SpiceImageSurfacesOps image_surfaces_ops = {
>          image_surfaces_get,
> @@ -1992,13 +1993,13 @@ void
> display_channel_process_surface_cmd(DisplayChannel *display,
> RedSurfaceCmd
>  void display_channel_update_compression(DisplayChannel *display,
> DisplayChannelClient *dcc)
>  {
>      if (dcc_get_jpeg_state(dcc) == SPICE_WAN_COMPRESSION_AUTO) {
> -        display->enable_jpeg = ((CommonGraphicsChannelClient*)dcc)-
> >is_low_bandwidth;
> +        display->enable_jpeg = dcc_is_low_bandwidth(dcc);
>      } else {
>          display->enable_jpeg = (dcc_get_jpeg_state(dcc) ==
> SPICE_WAN_COMPRESSION_ALWAYS);
>      }
>  
>      if (dcc_get_zlib_glz_state(dcc) == SPICE_WAN_COMPRESSION_AUTO) {
> -        display->enable_zlib_glz_wrap =
> ((CommonGraphicsChannelClient*)dcc)->is_low_bandwidth;
> +        display->enable_zlib_glz_wrap = dcc_is_low_bandwidth(dcc);
>      } else {
>          display->enable_zlib_glz_wrap = (dcc_get_zlib_glz_state(dcc)
> == SPICE_WAN_COMPRESSION_ALWAYS);
>      }
> diff --git a/server/red-worker.c b/server/red-worker.c
> index 9744131..34a8bff 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -400,14 +400,14 @@ static void flush_all_qxl_commands(RedWorker
> *worker)
>      flush_cursor_commands(worker);
>  }
>  
> -static int common_channel_config_socket(RedChannelClient *rcc)
> +int common_channel_config_socket(RedChannelClient *rcc)
>  {
>      RedClient *client = red_channel_client_get_client(rcc);
>      MainChannelClient *mcc = red_client_get_main(client);
>      RedsStream *stream = red_channel_client_get_stream(rcc);
> -    CommonGraphicsChannelClient *ccc =
> COMMON_GRAPHICS_CHANNEL_CLIENT(rcc);
>      int flags;
>      int delay_val;
> +    gboolean is_low_bandwidth;
>  
>      if ((flags = fcntl(stream->socket, F_GETFL)) == -1) {
>          spice_warning("accept failed, %s", strerror(errno));
> @@ -420,8 +420,8 @@ static int
> common_channel_config_socket(RedChannelClient *rcc)
>      }
>  
>      // TODO - this should be dynamic, not one time at channel
> creation
> -    ccc->is_low_bandwidth =
> main_channel_client_is_low_bandwidth(mcc);
> -    delay_val = ccc->is_low_bandwidth ? 0 : 1;
> +    is_low_bandwidth = main_channel_client_is_low_bandwidth(mcc);
> +    delay_val = is_low_bandwidth ? 0 : 1;
>      /* FIXME: Using Nagle's Algorithm can lead to apparent delays,
> depending
>       * on the delayed ack timeout on the other side.
>       * Instead of using Nagle's, we need to implement message
> buffering on
> @@ -436,7 +436,7 @@ static int
> common_channel_config_socket(RedChannelClient *rcc)
>      }
>      // TODO: move wide/narrow ack setting to red_channel.
>      red_channel_client_ack_set_client_window(rcc,
> -        ccc->is_low_bandwidth ?
> +        is_low_bandwidth ?
>          WIDE_CLIENT_ACK_WINDOW : NARROW_CLIENT_ACK_WINDOW);
>      return TRUE;
>  }
> @@ -452,11 +452,11 @@ CommonGraphicsChannel
> *red_worker_new_channel(RedWorker *worker, int size,
>  
>      spice_return_val_if_fail(worker, NULL);
>      spice_return_val_if_fail(channel_cbs, NULL);
> -    spice_return_val_if_fail(!channel_cbs->config_socket, NULL);
>      spice_return_val_if_fail(!channel_cbs->alloc_recv_buf, NULL);
>      spice_return_val_if_fail(!channel_cbs->release_recv_buf, NULL);
>  
> -    channel_cbs->config_socket = common_channel_config_socket;
> +    if (!channel_cbs->config_socket)
> +        channel_cbs->config_socket = common_channel_config_socket;
>      channel_cbs->alloc_recv_buf = common_alloc_recv_buf;
>      channel_cbs->release_recv_buf = common_release_recv_buf;
>  
> diff --git a/server/red-worker.h b/server/red-worker.h
> index 31a6f3e..60bdbec 100644
> --- a/server/red-worker.h
> +++ b/server/red-worker.h
> @@ -26,11 +26,10 @@ typedef struct RedWorker RedWorker;
>  
>  typedef struct CommonGraphicsChannelClient {
>      RedChannelClient base;
> -
> -    int is_low_bandwidth;
>  } CommonGraphicsChannelClient;
>  
> -#define COMMON_GRAPHICS_CHANNEL_CLIENT(Client)
> ((CommonGraphicsChannelClient*)(Client))
> +int common_channel_config_socket(RedChannelClient *rcc);
> +
>  #define COMMON_CLIENT_TIMEOUT (NSEC_PER_SEC * 30)
>  
>  #define CHANNEL_RECEIVE_BUF_SIZE 1024
> diff --git a/server/stream.c b/server/stream.c
> index 9e7fa3a..547ce5b 100644
> --- a/server/stream.c
> +++ b/server/stream.c
> @@ -356,7 +356,7 @@ static void before_reattach_stream(DisplayChannel
> *display,
>          agent = dcc_get_stream_agent(dcc, index);
>  
>          if (!dcc_use_video_encoder_rate_control(dcc) &&
> -            !((CommonGraphicsChannelClient*)dcc)->is_low_bandwidth)
> {
> +            !dcc_is_low_bandwidth(dcc)) {
>              continue;
>          }
>  
> @@ -647,7 +647,7 @@ static uint64_t
> get_initial_bit_rate(DisplayChannelClient *dcc, Stream *stream)
>               * If the network info is not initialized due to another
> reason,
>               * the low_bandwidth flag is FALSE.
>               */
> -            bit_rate = ((CommonGraphicsChannelClient*)dcc)-
> >is_low_bandwidth ?
> +            bit_rate = dcc_is_low_bandwidth(dcc) ?
>                  RED_STREAM_DEFAULT_LOW_START_BIT_RATE :
>                  RED_STREAM_DEFAULT_HIGH_START_BIT_RATE;
>          }


More information about the Spice-devel mailing list