From 030c92e213af6bd6f01fb0a0683fea9a6feacb65 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Fri, 6 Feb 2015 02:11:11 +0100
Subject: [PATCH] Client: Improve test_and_poll_server() ping test logic /
 timing.

---
 src/client/io.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/client/io.c b/src/client/io.c
index 694ebfb..ee4dcc2 100644
--- a/src/client/io.c
+++ b/src/client/io.c
@@ -204,6 +204,7 @@ static uint8_t read_worldstate()
 static void test_and_poll_server()
 {
     static time_t last_server_answer_time = 0;
+    static time_t last_pong_time = 0;
     static uint8_t ping_sent = 0;
     if (read_file_into_queue(world.file_server_out, &world.queue))
     {
@@ -220,9 +221,10 @@ static void test_and_poll_server()
     {
         send("PING");
         ping_sent = 1;
+        last_pong_time = now;
         return;
     }
-    exit_err(last_server_answer_time < now - 6, "Server not answering.");
+    exit_err(ping_sent && last_pong_time < now - 5, "Server not answering.");
 }
 
 
-- 
2.30.2