From 4e4313a0162999f961db391a2dcf943128040e56 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 13 Nov 2014 22:38:09 +0100 Subject: [PATCH] Client: Abort test_ping_pong() earlier when server known to be active. --- src/client/io.c | 7 ++++--- src/client/io.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/client/io.c b/src/client/io.c index ec72478..b3724b5 100644 --- a/src/client/io.c +++ b/src/client/io.c @@ -237,9 +237,10 @@ static void test_ping_pong(time_t last_server_answer_time) { static uint8_t ping_sent = 0; time_t now = time(0); - if (ping_sent && last_server_answer_time > now - 3) - { - ping_sent = 0; + if (ping_sent && last_server_answer_time > now - 3) /* Re-set if last */ + { /* ping was answered */ + ping_sent = 0; /* with server */ + return; /* activity. */ } if (!ping_sent && last_server_answer_time < now - 3) { diff --git a/src/client/io.h b/src/client/io.h index 344a8ee..33fc671 100644 --- a/src/client/io.h +++ b/src/client/io.h @@ -20,7 +20,7 @@ */ extern void send(char * msg); -/* Keep checking for user input, a changed worldstate file and the server's +/* Keep checking for user input, a changed worldstate file, and the server's * wakefulness. Update client's world representation on worldstate file changes. * Manipulate the client and send commands to server based on the user input as * interpreted by the control.h library. -- 2.30.2