From 8a1ef367e27e570cac40d3b09920a4a60c5f7e0b Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Sun, 27 Jun 2021 21:32:10 +0100 Subject: [PATCH] Treat failure of ubus_add_object() in ubus_init() as retry-able. 3c93e8eb41952a9c91699386132d6fe83050e9be regularised ubus_init() by avoiding logging calls (it can be called before logging is up) but it instead returned any error from ubus_add_object() which made such an error fatal. It turns out this is awkward, so this patch returns NULL always, so that the event-loop will continue attemping to connect to ubus forever. This is not necessarily optimal either, and should be looked at by a UBUS grown-up, but it does solve the immediate problem. --- src/ubus.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ubus.c b/src/ubus.c index 4d63006..88172a6 100644 --- a/src/ubus.c +++ b/src/ubus.c @@ -104,6 +104,8 @@ static void ubus_disconnect_cb(struct ubus_context *ubus) } } +/* Note that this cannot log, it either returns a fatal error, or NULL. + If daemon->ubus is left as NULL, it will be called again for another try. */ char *ubus_init() { struct ubus_context *ubus = NULL; @@ -117,9 +119,9 @@ char *ubus_init() if (ret) { ubus_destroy(ubus); - return (char *)ubus_strerror(ret); - } - + return NULL; + } + ubus->connection_lost = ubus_disconnect_cb; daemon->ubus = ubus; error_logged = 0;