[Spice-devel] [PATCH spice-server 01/10] main_channel: add routine for checking if a network test had been conducted and completed

Marc-André Lureau marcandre.lureau at gmail.com
Wed May 8 07:47:01 PDT 2013


ack


On Wed, May 8, 2013 at 4:06 PM, Yonit Halperin <yhalperi at redhat.com> wrote:

> ---
>  server/main_channel.c | 10 +++++++++-
>  server/main_channel.h |  6 ++++++
>  2 files changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/server/main_channel.c b/server/main_channel.c
> index dd927ab..4cf7e19 100644
> --- a/server/main_channel.c
> +++ b/server/main_channel.c
> @@ -164,6 +164,7 @@ enum NetTestStage {
>      NET_TEST_STAGE_WARMUP,
>      NET_TEST_STAGE_LATENCY,
>      NET_TEST_STAGE_RATE,
> +    NET_TEST_STAGE_COMPLETE,
>  };
>
>  static void main_channel_release_pipe_item(RedChannelClient *rcc,
> @@ -962,6 +963,7 @@ static int main_channel_handle_parsed(RedChannelClient
> *rcc, uint32_t size, uint
>                  if (roundtrip <= mcc->latency) {
>                      // probably high load on client or server result with
> incorrect values
>                      mcc->latency = 0;
> +                    mcc->net_test_stage = NET_TEST_STAGE_INVALID;
>                      spice_printerr("net test: invalid values, latency %"
> PRIu64
>                                 " roundtrip %" PRIu64 ". assuming high"
>                                 "bandwidth", mcc->latency, roundtrip);
> @@ -969,18 +971,19 @@ static int
> main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
>                  }
>                  mcc->bitrate_per_sec = (uint64_t)(NET_TEST_BYTES * 8) *
> 1000000
>                                          / (roundtrip - mcc->latency);
> +                mcc->net_test_stage = NET_TEST_STAGE_COMPLETE;
>                  spice_printerr("net test: latency %f ms, bitrate
> %"PRIu64" bps (%f Mbps)%s",
>                             (double)mcc->latency / 1000,
>                             mcc->bitrate_per_sec,
>                             (double)mcc->bitrate_per_sec / 1024 / 1024,
>                             main_channel_client_is_low_bandwidth(mcc) ? "
> LOW BANDWIDTH" : "");
> -                mcc->net_test_stage = NET_TEST_STAGE_INVALID;
>                  break;
>              default:
>                  spice_printerr("invalid net test stage, ping id %d test
> id %d stage %d",
>                             ping->id,
>                             mcc->net_test_id,
>                             mcc->net_test_stage);
> +                mcc->net_test_stage = NET_TEST_STAGE_INVALID;
>              }
>              break;
>          }
> @@ -1139,6 +1142,11 @@ void main_channel_close(MainChannel *main_chan)
>      }
>  }
>
> +int main_channel_client_is_network_info_initialized(MainChannelClient
> *mcc)
> +{
> +    return mcc->net_test_stage == NET_TEST_STAGE_COMPLETE;
> +}
> +
>  int main_channel_client_is_low_bandwidth(MainChannelClient *mcc)
>  {
>      // TODO: configurable?
> diff --git a/server/main_channel.h b/server/main_channel.h
> index b2f0e6f..27367a4 100644
> --- a/server/main_channel.h
> +++ b/server/main_channel.h
> @@ -67,9 +67,15 @@ int main_channel_getsockname(MainChannel *main_chan,
> struct sockaddr *sa, sockle
>  int main_channel_getpeername(MainChannel *main_chan, struct sockaddr *sa,
> socklen_t *salen);
>  uint32_t main_channel_client_get_link_id(MainChannelClient *mcc);
>
> +/*
> + * return TRUE if network test had been completed successfully.
> + * If FALSE, bitrate_per_sec is set to MAX_UINT64 and the roundtrip is
> set to 0
> + */
> +int main_channel_client_is_network_info_initialized(MainChannelClient
> *mcc);
>  int main_channel_client_is_low_bandwidth(MainChannelClient *mcc);
>  uint64_t main_channel_client_get_bitrate_per_sec(MainChannelClient *mcc);
>  uint64_t main_channel_client_get_roundtrip_ms(MainChannelClient *mcc);
> +
>  int main_channel_is_connected(MainChannel *main_chan);
>  RedChannelClient* main_channel_client_get_base(MainChannelClient* mcc);
>
> --
> 1.8.1.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>



-- 
Marc-André Lureau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20130508/90219bd5/attachment.html>


More information about the Spice-devel mailing list