ask-password: round up when determining sleep time
authorLennart Poettering <lennart@poettering.net>
Tue, 13 Feb 2018 22:57:57 +0000 (23:57 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 13 Feb 2018 23:03:05 +0000 (00:03 +0100)
We should rather sleep to much than too little. This otherwise might
result in a busy loop, because we slept too little and then recheck
again coming to the conclusion we need to go to sleep again, and so on.

src/shared/ask-password-api.c

index fbe8d06..d727f5b 100644 (file)
@@ -291,7 +291,7 @@ int ask_password_tty(
                                 goto finish;
                         }
 
-                        sleep_for = (int) ((until - y) / USEC_PER_MSEC);
+                        sleep_for = (int) DIV_ROUND_UP(until - y, USEC_PER_MSEC);
                 }
 
                 if (flag_file)