[Spice-devel] [spice-server v1 2/2] mcc: early return and lower indentation
Victor Toso
victortoso at redhat.com
Wed Sep 7 13:15:24 UTC 2016
main_channel_client_start_net_test() checks MainChannelClient already
which is the single reason why main_channel_client_push_ping() could
fail. Reorganizing this code a little bit.
---
server/main-channel-client.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/server/main-channel-client.c b/server/main-channel-client.c
index 20cf932..fd4802a 100644
--- a/server/main-channel-client.c
+++ b/server/main-channel-client.c
@@ -142,16 +142,18 @@ void main_channel_client_start_net_test(MainChannelClient *mcc, int test_rate)
if (!mcc || mcc->net_test_id) {
return;
}
- if (test_rate) {
- if (main_channel_client_push_ping(mcc, NET_TEST_WARMUP_BYTES)
- && main_channel_client_push_ping(mcc, 0)
- && main_channel_client_push_ping(mcc, NET_TEST_BYTES)) {
- mcc->net_test_id = mcc->ping_id - 2;
- mcc->net_test_stage = NET_TEST_STAGE_WARMUP;
- }
- } else {
+
+ if (!test_rate) {
red_channel_client_start_connectivity_monitoring(&mcc->base, CLIENT_CONNECTIVITY_TIMEOUT);
+ return;
}
+
+ main_channel_client_push_ping(mcc, NET_TEST_WARMUP_BYTES);
+ main_channel_client_push_ping(mcc, 0);
+ main_channel_client_push_ping(mcc, NET_TEST_BYTES);
+
+ mcc->net_test_id = mcc->ping_id - 2;
+ mcc->net_test_stage = NET_TEST_STAGE_WARMUP;
}
static RedPipeItem *red_ping_item_new(int size)
--
2.7.4
More information about the Spice-devel
mailing list