helper_thread: cleanups
authorVincent Fu <vincent.fu@wdc.com>
Tue, 28 Apr 2020 17:27:14 +0000 (11:27 -0600)
committerVincent Fu <vincent.fu@wdc.com>
Wed, 29 Apr 2020 11:23:07 +0000 (05:23 -0600)
- instead of always using a timeout of DISK_UTIL_MSEC, use a possibly shorter
  period for the select() timeout
- drop the timespec_add_msec() call because the target is overwritten in short
  order by clock_gettime()

Signed-off-by: Vincent Fu <vincent.fu@wdc.com>
helper_thread.c

index 7874985504be2aa6c4c82c7683320c39409d927d..90bfab5c0ce978039a289c145f248a31d6289652 100644 (file)
@@ -164,13 +164,11 @@ static void *helper_thread_main(void *data)
        while (!ret && !hd->exit) {
                uint64_t since_du, since_ss = 0;
                struct timeval timeout = {
-                       .tv_sec  = DISK_UTIL_MSEC / 1000,
-                       .tv_usec = (DISK_UTIL_MSEC % 1000) * 1000,
+                       .tv_sec  = msec_to_next_event / 1000,
+                       .tv_usec = (msec_to_next_event % 1000) * 1000,
                };
                fd_set rfds, efds;
 
-               timespec_add_msec(&ts, msec_to_next_event);
-
                if (read_from_pipe(hd->pipe[0], &action, sizeof(action)) < 0) {
                        FD_ZERO(&rfds);
                        FD_SET(hd->pipe[0], &rfds);