time: limit usec_sleep() to maximum intervals of 1 second
authorJens Axboe <axboe@kernel.dk>
Mon, 13 Jan 2020 21:51:35 +0000 (14:51 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 13 Jan 2020 21:51:35 +0000 (14:51 -0700)
The total sleep may be much longer, but wakeup every ~1 second at least
to check if we got signaled to exit.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
time.c

diff --git a/time.c b/time.c
index 1999969..cd0e2a8 100644 (file)
--- a/time.c
+++ b/time.c
@@ -57,6 +57,13 @@ uint64_t usec_sleep(struct thread_data *td, unsigned long usec)
                if (ts >= 1000000) {
                        req.tv_sec = ts / 1000000;
                        ts -= 1000000 * req.tv_sec;
+                       /*
+                        * Limit sleep to ~1 second at most, otherwise we
+                        * don't notice then someone signaled the job to
+                        * exit manually.
+                        */
+                       if (req.tv_sec > 1)
+                               req.tv_sec = 1;
                } else
                        req.tv_sec = 0;