[LEDE-DEV] [PATCH] ubus cli: wait_for: fix race causing false timeouts

Felix Fietkau nbd at nbd.name
Fri Oct 7 05:09:06 PDT 2016


On 2016-10-07 13:57, Zefir Kurtisi wrote:
> In ubus_cli_wait_for() there is a critical section between
> initially checking for the requested services and the
> following handling of 'ubus.object.add' events.
> 
> In our system we let procd (re)start services and synchronize
> inter-service dependencies by using 'ubus wait_for' in the
> initscripts' service_started() functions. There we observe
> that 'wait_for' randomly is waiting for the full timeout
> and returning UBUS_STATUS_TIMEOUT, even if the service it
> is waiting for is already up and running.
> 
> This happens when the service is started in the critical
> section mentioned above. This commit adds periodic lookup
> for the requested services while waiting for the 'add' event
> and with that fixes the observed failure.
> 
> Signed-off-by: Zefir Kurtisi <zefir.kurtisi at neratec.com>
Instead of introducing yet another timer, wouldn't it also be possible
to close this race window by registering the event handler before
attempting the lookup?

- Felix



More information about the Lede-dev mailing list