mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Re-order UBus initialisation to avoid logging before logs set up.
This commit is contained in:
@@ -442,8 +442,10 @@ int main (int argc, char **argv)
|
||||
if (option_bool(OPT_UBUS))
|
||||
#ifdef HAVE_UBUS
|
||||
{
|
||||
char *err;
|
||||
daemon->ubus = NULL;
|
||||
ubus_init();
|
||||
if ((err = ubus_init()))
|
||||
die(_("UBus error: %s"), err, EC_MISC);
|
||||
}
|
||||
#else
|
||||
die(_("UBus not available: set HAVE_UBUS in src/config.h"), NULL, EC_BADCONF);
|
||||
@@ -1195,20 +1197,20 @@ int main (int argc, char **argv)
|
||||
if (daemon->dbus)
|
||||
my_syslog(LOG_INFO, _("connected to system DBus"));
|
||||
}
|
||||
check_dbus_listeners();
|
||||
check_dbus_listeners();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UBUS
|
||||
if (option_bool(OPT_UBUS))
|
||||
/* if we didn't create a UBus connection, retry now. */
|
||||
if (option_bool(OPT_UBUS) && !daemon->ubus)
|
||||
{
|
||||
/* if we didn't create a UBus connection, retry now. */
|
||||
if (!daemon->ubus)
|
||||
{
|
||||
ubus_init();
|
||||
}
|
||||
|
||||
check_ubus_listeners();
|
||||
}
|
||||
char *err;
|
||||
if ((err = ubus_init()))
|
||||
my_syslog(LOG_WARNING, _("UBus error: %s"), err);
|
||||
if (daemon->ubus)
|
||||
my_syslog(LOG_INFO, _("connected to system UBus"));
|
||||
}
|
||||
check_ubus_listeners();
|
||||
#endif
|
||||
|
||||
check_dns_listeners(now);
|
||||
|
||||
@@ -1543,7 +1543,7 @@ void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname);
|
||||
|
||||
/* ubus.c */
|
||||
#ifdef HAVE_UBUS
|
||||
void ubus_init(void);
|
||||
char *ubus_init(void);
|
||||
void set_ubus_listeners(void);
|
||||
void check_ubus_listeners(void);
|
||||
void ubus_event_bcast(const char *type, const char *mac, const char *ip, const char *name, const char *interface);
|
||||
|
||||
31
src/ubus.c
31
src/ubus.c
@@ -76,42 +76,27 @@ static void ubus_disconnect_cb(struct ubus_context *ubus)
|
||||
}
|
||||
}
|
||||
|
||||
void ubus_init()
|
||||
char *ubus_init()
|
||||
{
|
||||
struct ubus_context *ubus = NULL;
|
||||
int ret = 0;
|
||||
|
||||
ubus = ubus_connect(NULL);
|
||||
if (!ubus)
|
||||
{
|
||||
if (!error_logged)
|
||||
{
|
||||
my_syslog(LOG_ERR, _("Cannot initialize UBus: connection failed"));
|
||||
error_logged = 1;
|
||||
}
|
||||
|
||||
ubus_destroy(ubus);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(ubus = ubus_connect(NULL)))
|
||||
return NULL;
|
||||
|
||||
ubus_object.name = daemon->ubus_name;
|
||||
ret = ubus_add_object(ubus, &ubus_object);
|
||||
if (ret)
|
||||
{
|
||||
if (!error_logged)
|
||||
{
|
||||
my_syslog(LOG_ERR, _("Cannot add object to UBus: %s"), ubus_strerror(ret));
|
||||
error_logged = 1;
|
||||
}
|
||||
ubus_destroy(ubus);
|
||||
return;
|
||||
}
|
||||
|
||||
return ubus_strerror(ret);
|
||||
}
|
||||
|
||||
ubus->connection_lost = ubus_disconnect_cb;
|
||||
daemon->ubus = ubus;
|
||||
error_logged = 0;
|
||||
|
||||
my_syslog(LOG_INFO, _("Connected to system UBus"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void set_ubus_listeners()
|
||||
|
||||
Reference in New Issue
Block a user