runsvdir: do not miss closely spaced service dir changes
authorEric Lammerts <busybox@lists.lammerts.org>
Mon, 6 Dec 2010 00:26:26 +0000 (01:26 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 6 Dec 2010 00:26:26 +0000 (01:26 +0100)
Signed-off-by: Eric Lammerts <busybox@lists.lammerts.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
runit/runsvdir.c

index e77eeff042900b8c4f1006bcf1c9eec950eb51a5..16666423703ecd2f0c2ee89aa916901ba361ac13 100644 (file)
@@ -312,8 +312,11 @@ int runsvdir_main(int argc UNUSED_PARAM, char **argv)
                                                last_mtime = s.st_mtime;
                                                last_dev = s.st_dev;
                                                last_ino = s.st_ino;
-                                               //if (now <= mtime)
-                                               //      sleep(1);
+                                               /* if the svdir changed this very second, wait until the
+                                                * next second, because we won't be able to detect more
+                                                * changes within this second */
+                                               while (time(NULL) == last_mtime)
+                                                       usleep(100000);
                                                need_rescan = do_rescan();
                                                while (fchdir(curdir) == -1) {
                                                        warn2_cannot("change directory, pausing", "");