coldplug: only start hotplug timer after udevtrigger finished
authorGabor Juhos <juhosg@openwrt.org>
Tue, 10 Sep 2013 14:56:10 +0000 (16:56 +0200)
committerJohn Crispin <blogic@openwrt.org>
Fri, 13 Sep 2013 15:37:26 +0000 (17:37 +0200)
Currently the last event timer for hotplug is
started after the udevtrigger process is forked.

Starting the timer means that the first hotplug
event must come in before the timer expires.
During this time the kernel must load the binary
of the udevtrigger from the underlying rootfs
which can be time consuming on slow systems.

On such systems, the timer expires before the
first hotplug event happens which results in
broken behaviour. Due to the missing device nodes,
not the ubus nor the procd code works correctly in
that case.

Change the code to only start the hotplug last
event timer after the udevtrigger process finishes.
This ensures that the delay caused by accessing the
underlying filesystem does not affects the desired
behaviour.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
coldplug.c

index d5997f8..b8c0eaf 100644 (file)
@@ -34,6 +34,7 @@ static void coldplug_complete(struct uloop_timeout *t)
 static void udevtrigger_complete(struct uloop_process *proc, int ret)
 {
        DEBUG(2, "Finished udevtrigger\n");
 static void udevtrigger_complete(struct uloop_process *proc, int ret)
 {
        DEBUG(2, "Finished udevtrigger\n");
+       hotplug_last_event(coldplug_complete);
 }
 
 void procd_coldplug(void)
 }
 
 void procd_coldplug(void)
@@ -59,7 +60,6 @@ void procd_coldplug(void)
                return;
        }
 
                return;
        }
 
-       hotplug_last_event(coldplug_complete);
        uloop_process_add(&udevtrigger);
 
        DEBUG(2, "Launched coldplug instance, pid=%d\n", (int) udevtrigger.pid);
        uloop_process_add(&udevtrigger);
 
        DEBUG(2, "Launched coldplug instance, pid=%d\n", (int) udevtrigger.pid);