Fix select timeout.
authorroot <root@braid.x>
Thu, 17 Apr 2008 15:58:20 +0000 (17:58 +0200)
committerroot <root@braid.x>
Thu, 17 Apr 2008 15:58:20 +0000 (17:58 +0200)
Under Linux, select() modifies the timeval pointed to by the last
parameter; it contains the time that was not slept because an fd
in one of the given fd sets became ready.

It is hence necessary to reset the time to be slept in each iteration
off dss' select loop.

dss.c

diff --git a/dss.c b/dss.c
index 6124060..b475ba7 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -747,19 +747,24 @@ static int select_loop(void)
 {
        int ret;
        /* check every 60 seconds for free disk space */
-       struct timeval tv = {.tv_sec = 60, .tv_usec = 0};
+       struct timeval tv;
 
        for (;;) {
                fd_set rfds;
                int low_disk_space;
                char **rsync_argv;
-               struct timeval now, *tvp = &tv;
+               struct timeval now, *tvp;
 
                if (rm_pid)
                        tvp = NULL; /* sleep until rm process dies */
+               else { /* sleep one minute */
+                       tv.tv_sec = 60;
+                       tv.tv_usec = 0;
+                       tvp = &tv;
+               }
                FD_ZERO(&rfds);
                FD_SET(signal_pipe, &rfds);
-               DSS_DEBUG_LOG("tvp: %p, tv_sec: %lu\n", tvp, (long unsigned) tv.tv_sec);
+               DSS_DEBUG_LOG("tvp: %p, tv_sec : %lu\n", tvp, (long unsigned) tv.tv_sec);
                ret = dss_select(signal_pipe + 1, &rfds, NULL, tvp);
                if (ret < 0)
                        return ret;