8f2528
diff --git a/serverloop.c b/serverloop.c
8f2528
index b5eb3440..1535eeb2 100644
8f2528
--- a/serverloop.c
8f2528
+++ b/serverloop.c
8f2528
@@ -225,9 +225,10 @@ wait_until_can_do_something(int connection_in, int connection_out,
8f2528
 		uint64_t keepalive_ms =
8f2528
 		    (uint64_t)options.client_alive_interval * 1000;
8f2528
 
8f2528
-		client_alive_scheduled = 1;
8f2528
-		if (max_time_ms == 0 || max_time_ms > keepalive_ms)
8f2528
+		if (max_time_ms == 0 || max_time_ms > keepalive_ms) {
8f2528
 			max_time_ms = keepalive_ms;
8f2528
+			client_alive_scheduled = 1;
8f2528
+		}
8f2528
 	}
8f2528
 
8f2528
 #if 0
8f2528