make procd wait for ubus to come up
authorJohn Crispin <blogic@openwrt.org>
Mon, 6 Oct 2014 18:15:24 +0000 (20:15 +0200)
committerJohn Crispin <blogic@openwrt.org>
Mon, 6 Oct 2014 18:53:55 +0000 (20:53 +0200)
Signed-off-by: John Crispin <blogic@openwrt.org>
procd.h
state.c
ubus.c

diff --git a/procd.h b/procd.h
index 4ae0dc9..66d183c 100644 (file)
--- a/procd.h
+++ b/procd.h
@@ -35,6 +35,7 @@ void ubus_init_service(struct ubus_context *ctx);
 void ubus_init_system(struct ubus_context *ctx);
 
 void procd_state_next(void);
 void ubus_init_system(struct ubus_context *ctx);
 
 void procd_state_next(void);
+void procd_state_ubus_connect(void);
 void procd_shutdown(int event);
 void procd_early(void);
 void procd_preinit(void);
 void procd_shutdown(int event);
 void procd_early(void);
 void procd_preinit(void);
diff --git a/state.c b/state.c
index c5d90b6..41e4471 100644 (file)
--- a/state.c
+++ b/state.c
@@ -27,6 +27,7 @@
 enum {
        STATE_NONE = 0,
        STATE_EARLY,
 enum {
        STATE_NONE = 0,
        STATE_EARLY,
+       STATE_UBUS,
        STATE_INIT,
        STATE_RUNNING,
        STATE_SHUTDOWN,
        STATE_INIT,
        STATE_RUNNING,
        STATE_SHUTDOWN,
@@ -49,16 +50,17 @@ static void state_enter(void)
                procd_coldplug();
                break;
 
                procd_coldplug();
                break;
 
-       case STATE_INIT:
+       case STATE_UBUS:
                // try to reopen incase the wdt was not available before coldplug
                watchdog_init(0);
                LOG("- ubus -\n");
                procd_connect_ubus();
                // try to reopen incase the wdt was not available before coldplug
                watchdog_init(0);
                LOG("- ubus -\n");
                procd_connect_ubus();
-
-               LOG("- init -\n");
                service_init();
                service_start_early("ubus", ubus_cmd);
                service_init();
                service_start_early("ubus", ubus_cmd);
+               break;
 
 
+       case STATE_INIT:
+               LOG("- init -\n");
                procd_inittab();
                procd_inittab_run("respawn");
                procd_inittab_run("askconsole");
                procd_inittab();
                procd_inittab_run("respawn");
                procd_inittab_run("askconsole");
@@ -118,6 +120,12 @@ void procd_state_next(void)
        state_enter();
 }
 
        state_enter();
 }
 
+void procd_state_ubus_connect(void)
+{
+       if (state == STATE_UBUS)
+               procd_state_next();
+}
+
 void procd_shutdown(int event)
 {
        if (state >= STATE_SHUTDOWN)
 void procd_shutdown(int event)
 {
        if (state >= STATE_SHUTDOWN)
diff --git a/ubus.c b/ubus.c
index bb3908e..211a1ec 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -57,6 +57,7 @@ ubus_connect_cb(struct uloop_timeout *timeout)
 
        DEBUG(2, "Connected to ubus, id=%08x\n", ctx->local_id);
        ubus_add_uloop(ctx);
 
        DEBUG(2, "Connected to ubus, id=%08x\n", ctx->local_id);
        ubus_add_uloop(ctx);
+       procd_state_ubus_connect();
 }
 
 void
 }
 
 void