[Spice-devel] [spice-server v1 1/2] mcc: early return and lower indentation
Victor Toso
lists at victortoso.com
Wed Sep 7 13:31:35 UTC 2016
Hi,
On Wed, Sep 07, 2016 at 09:21:42AM -0400, Frediano Ziglio wrote:
> >
> > ---
> > server/main-channel-client.c | 97
> > +++++++++++++++++++++-----------------------
> > 1 file changed, 47 insertions(+), 50 deletions(-)
> >
> > diff --git a/server/main-channel-client.c b/server/main-channel-client.c
> > index 12151a7..20cf932 100644
> > --- a/server/main-channel-client.c
> > +++ b/server/main-channel-client.c
> > @@ -376,59 +376,56 @@ void main_channel_client_handle_pong(MainChannelClient
> > *mcc, SpiceMsgPing *ping,
> >
> > roundtrip = g_get_monotonic_time() - ping->timestamp;
> >
> > - if (ping->id == mcc->net_test_id) {
> > - switch (mcc->net_test_stage) {
> > - case NET_TEST_STAGE_WARMUP:
> > - mcc->net_test_id++;
> > - mcc->net_test_stage = NET_TEST_STAGE_LATENCY;
> > - mcc->latency = roundtrip;
> > - break;
> > - case NET_TEST_STAGE_LATENCY:
> > - mcc->net_test_id++;
> > - mcc->net_test_stage = NET_TEST_STAGE_RATE;
> > - mcc->latency = MIN(mcc->latency, roundtrip);
> > - break;
> > - case NET_TEST_STAGE_RATE:
> > - mcc->net_test_id = 0;
> > - if (roundtrip <= mcc->latency) {
> > - // probably high load on client or server result with
> > incorrect values
> > - spice_printerr("net test: invalid values, latency %"
> > PRIu64
> > - " roundtrip %" PRIu64 ". assuming high"
> > - "bandwidth", mcc->latency, roundtrip);
> > - mcc->latency = 0;
> > - mcc->net_test_stage = NET_TEST_STAGE_INVALID;
> > -
> > red_channel_client_start_connectivity_monitoring(&mcc->base,
> > -
> > CLIENT_CONNECTIVITY_TIMEOUT);
> > - break;
> > - }
> > - 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" : "");
> > - red_channel_client_start_connectivity_monitoring(&mcc->base,
> > -
> > CLIENT_CONNECTIVITY_TIMEOUT);
> > - 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;
> > - }
> > - return;
> > - } else {
> > - /*
> > - * channel client monitors the connectivity using ping-pong messages
> > - */
>
> Why did you remove this comment ?
If ping->id != net_test_id we let the red-channel handle the pong, I
thought the comment was a bit redundant but it should not be removed in
this patch, for sure.
I'll put it back.
>
> > + if (ping->id != mcc->net_test_id) {
> > red_channel_client_handle_message(rcc, size, SPICE_MSGC_PONG, ping);
> > - }
> > #ifdef RED_STATISTICS
> > - stat_update_value(red_channel_client_get_channel(rcc)->reds, roundtrip);
> > + stat_update_value(red_channel_client_get_channel(rcc)->reds,
> > roundtrip);
> > #endif
> > + return;
> > + }
> > +
> > + switch (mcc->net_test_stage) {
> > + case NET_TEST_STAGE_WARMUP:
> > + mcc->net_test_id++;
> > + mcc->net_test_stage = NET_TEST_STAGE_LATENCY;
> > + mcc->latency = roundtrip;
> > + break;
> > + case NET_TEST_STAGE_LATENCY:
> > + mcc->net_test_id++;
> > + mcc->net_test_stage = NET_TEST_STAGE_RATE;
> > + mcc->latency = MIN(mcc->latency, roundtrip);
> > + break;
> > + case NET_TEST_STAGE_RATE:
> > + mcc->net_test_id = 0;
> > + if (roundtrip <= mcc->latency) {
> > + // probably high load on client or server result with incorrect
> > values
> > + spice_printerr("net test: invalid values, latency %" PRIu64
> > + " roundtrip %" PRIu64 ". assuming high"
> > + "bandwidth", mcc->latency, roundtrip);
> > + mcc->latency = 0;
> > + mcc->net_test_stage = NET_TEST_STAGE_INVALID;
> > + red_channel_client_start_connectivity_monitoring(&mcc->base,
> > +
> > CLIENT_CONNECTIVITY_TIMEOUT);
> > + break;
> > + }
> > + 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" : "");
> > + red_channel_client_start_connectivity_monitoring(&mcc->base,
> > +
> > CLIENT_CONNECTIVITY_TIMEOUT);
> > + 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;
> > + }
> > }
> >
> > void main_channel_client_handle_migrate_end(MainChannelClient *mcc)
>
> Otherwise it's fine.
Thanks,
>
> Frediano
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list