[Spice-devel] [PATCH 5/8] Simplify serial sending packets

Jonathon Jongsma jjongsma at redhat.com
Thu Sep 22 07:55:01 UTC 2016


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


On Mon, 2016-09-19 at 09:30 +0100, Frediano Ziglio wrote:
> serial was the future serial to send while last_sent_serial was the
> last sent.
> serial sent started from 1.
> To make sure sequence variable is updated just before sending the
> message, not every message prepared.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/red-channel-client-private.h |  1 -
>  server/red-channel-client.c         | 31 +++++--------------------
> ------
>  2 files changed, 5 insertions(+), 27 deletions(-)
> 
> diff --git a/server/red-channel-client-private.h b/server/red-
> channel-client-private.h
> index 532bfa3..c169f62 100644
> --- a/server/red-channel-client-private.h
> +++ b/server/red-channel-client-private.h
> @@ -43,7 +43,6 @@ struct RedChannelClientPrivate
>          uint32_t size;
>          RedPipeItem *item;
>          int blocked;
> -        uint64_t serial;
>          uint64_t last_sent_serial;
>  
>          struct {
> diff --git a/server/red-channel-client.c b/server/red-channel-
> client.c
> index 4108be0..1c2fb15 100644
> --- a/server/red-channel-client.c
> +++ b/server/red-channel-client.c
> @@ -166,26 +166,9 @@ static void
> red_channel_client_reset_send_data(RedChannelClient *rcc)
>      rcc->priv->send_data.header.set_msg_type(&rcc->priv-
> >send_data.header, 0);
>      rcc->priv->send_data.header.set_msg_size(&rcc->priv-
> >send_data.header, 0);
>  
> -    /* Keeping the serial consecutive: resetting it if
> reset_send_data
> -     * has been called before, but no message has been sent since
> then.
> -     */
> -    if (rcc->priv->send_data.last_sent_serial != rcc->priv-
> >send_data.serial) {
> -        spice_assert(rcc->priv->send_data.serial - rcc->priv-
> >send_data.last_sent_serial == 1);
> -        /*  When the urgent marshaller is active, the serial was
> incremented by
> -         *  the call to reset_send_data that was made for the main
> marshaller.
> -         *  The urgent msg receives this serial, and the main msg
> serial is
> -         *  the following one. Thus, (rcc->priv->send_data.serial -
> rcc->priv->send_data.last_sent_serial)
> -         *  should be 1 in this case*/
> -        if (!red_channel_client_urgent_marshaller_is_active(rcc)) {
> -            rcc->priv->send_data.serial = rcc->priv-
> >send_data.last_sent_serial;
> -        }
> -    }
> -    rcc->priv->send_data.serial++;
> -
>      if (!rcc->priv->is_mini_header) {
>          spice_assert(rcc->priv->send_data.marshaller != rcc->priv-
> >send_data.urgent.marshaller);
>          rcc->priv->send_data.header.set_msg_sub_list(&rcc->priv-
> >send_data.header, 0);
> -        rcc->priv->send_data.header.set_msg_serial(&rcc->priv-
> >send_data.header, rcc->priv->send_data.serial);
>      }
>  }
>  
> @@ -304,10 +287,6 @@ static void
> red_channel_client_restore_main_sender(RedChannelClient *rcc)
>      spice_marshaller_reset(rcc->priv->send_data.urgent.marshaller);
>      rcc->priv->send_data.marshaller = rcc->priv-
> >send_data.main.marshaller;
>      rcc->priv->send_data.header.data = rcc->priv-
> >send_data.main.header_data;
> -    if (!rcc->priv->is_mini_header) {
> -        rcc->priv->send_data.header.set_msg_serial(&rcc->priv-
> >send_data.header,
> -                                                   rcc->priv-
> >send_data.serial);
> -    }
>      rcc->priv->send_data.item = rcc->priv->send_data.main.item;
>  }
>  
> @@ -589,7 +568,7 @@ static void
> full_header_set_msg_serial(SpiceDataHeaderOpaque *header, uint64_t s
>  
>  static void mini_header_set_msg_serial(SpiceDataHeaderOpaque
> *header, uint64_t serial)
>  {
> -    spice_error("attempt to set header serial on mini header");
> +    /* ignore serial, not supported by mini header */
>  }
>  
>  static void full_header_set_msg_sub_list(SpiceDataHeaderOpaque
> *header, uint32_t sub_list)
> @@ -1254,8 +1233,9 @@ void
> red_channel_client_begin_send_message(RedChannelClient *rcc)
>      rcc->priv->send_data.header.set_msg_size(&rcc->priv-
> >send_data.header,
>                                               rcc->priv-
> >send_data.size -
>                                               rcc->priv-
> >send_data.header.header_size);
> +    rcc->priv->send_data.header.set_msg_serial(&rcc->priv-
> >send_data.header,
> +                                               ++rcc->priv-
> >send_data.last_sent_serial);
>      rcc->priv->ack_data.messages_window++;
> -    rcc->priv->send_data.last_sent_serial = rcc->priv-
> >send_data.serial;
>      rcc->priv->send_data.header.data = NULL; /* avoid writing to
> this until we have a new message */
>      red_channel_client_send(rcc);
>  }
> @@ -1275,13 +1255,12 @@ SpiceMarshaller
> *red_channel_client_switch_to_urgent_sender(RedChannelClient *rc
>  
>  uint64_t red_channel_client_get_message_serial(RedChannelClient
> *rcc)
>  {
> -    return rcc->priv->send_data.serial;
> +    return rcc->priv->send_data.last_sent_serial + 1;
>  }
>  
>  void red_channel_client_set_message_serial(RedChannelClient *rcc,
> uint64_t serial)
>  {
> -    rcc->priv->send_data.last_sent_serial = serial;
> -    rcc->priv->send_data.serial = serial;
> +    rcc->priv->send_data.last_sent_serial = serial - 1;
>  }
>  
>  static inline gboolean client_pipe_add(RedChannelClient *rcc,
> RedPipeItem *item, RingItem *pos)


More information about the Spice-devel mailing list