home · contact · privacy
Client: Abort test_ping_pong() earlier when server known to be active.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 13 Nov 2014 21:38:09 +0000 (22:38 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 13 Nov 2014 21:38:09 +0000 (22:38 +0100)
src/client/io.c
src/client/io.h

index ec724786a4b1b87bf607f33b08d3556b273a46cd..b3724b5ffaf566cc51322d023961f2a945c2aa7a 100644 (file)
@@ -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)
     {
index 344a8eebb793950688f367d6f9b9d38f6d6a4412..33fc671ec6fd8f9ea749012b73d4e9a84a9b6517 100644 (file)
@@ -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.