From 9286d16672b26c9fe7cb9dbf827a43a910df5559 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sat, 1 Nov 2014 23:23:47 +0100 Subject: [PATCH] kmodloader takes longer than wdt timeout on systms with slow flash the watchdog will trigger when a lot of modules are included in the image. Signed-off-by: John Crispin --- initd/init.c | 14 +++++++++++--- watchdog.c | 7 ++++++- watchdog.h | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/initd/init.c b/initd/init.c index d8490f8..0d201bc 100644 --- a/initd/init.c +++ b/initd/init.c @@ -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(); diff --git a/watchdog.c b/watchdog.c index 399f6af..3c097e2 100644 --- a/watchdog.c +++ b/watchdog.c @@ -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); } diff --git a/watchdog.h b/watchdog.h index a774dd7..015fa93 100644 --- a/watchdog.h +++ b/watchdog.h @@ -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 -- 2.25.1