kmodloader takes longer than wdt timeout
authorJohn Crispin <blogic@openwrt.org>
Sat, 1 Nov 2014 22:23:47 +0000 (23:23 +0100)
committerJohn Crispin <blogic@openwrt.org>
Wed, 5 Nov 2014 15:23:20 +0000 (16:23 +0100)
on systms with slow flash the watchdog will trigger when a lot of modules are
included in the image.

Signed-off-by: John Crispin <blogic@openwrt.org>
initd/init.c
watchdog.c
watchdog.h

index d8490f8505c09a08857464386593ad5f5a40cf2a..0d201bc33ffa46d1fad1488e7cc27082ae64869d 100644 (file)
@@ -99,10 +99,18 @@ main(int argc, char **argv)
                ERROR("Failed to start kmodloader\n");
                exit(-1);
        }
-       if (pid <= 0)
+       if (pid <= 0) {
                ERROR("Failed to start kmodloader instance\n");
-       else
-               waitpid(pid, NULL, 0);
+       } else {
+               int i;
+
+               for (i = 0; i < 120; i++) {
+                       if (waitpid(pid, NULL, WNOHANG) > 0)
+                               break;
+                       sleep(1);
+                       watchdog_ping();
+               }
+       }
        uloop_init();
        preinit();
        uloop_run();
index 399f6af7f1a9cff0be7d91dcdcb9e1d63e1b4ea7..3c097e2273c55c34f90c251588aa0630a64f7299 100644 (file)
@@ -32,11 +32,16 @@ static struct uloop_timeout wdt_timeout;
 static int wdt_fd = -1;
 static int wdt_frequency = 5;
 
-static void watchdog_timeout_cb(struct uloop_timeout *t)
+void watchdog_ping(void)
 {
        DEBUG(4, "Ping\n");
        if (write(wdt_fd, "X", 1) < 0)
                ERROR("WDT failed to write: %s\n", strerror(errno));
+}
+
+static void watchdog_timeout_cb(struct uloop_timeout *t)
+{
+       watchdog_ping();
        uloop_timeout_set(t, wdt_frequency * 1000);
 }
 
index a774dd734d0a6e92855993471ae01d07c83766cb..015fa93b5865c81c6af445e434aed8bed88256ea 100644 (file)
@@ -22,5 +22,6 @@ int watchdog_frequency(int frequency);
 void watchdog_set_stopped(bool val);
 bool watchdog_get_stopped(void);
 void watchdog_no_cloexec(void);
+void watchdog_ping(void);
 
 #endif