main: move module init into nl80211_appeared

In preparation for integrating IWD_MODULE into modules which require
nl80211 we move the module init into the nl80211_appeared callback.
This will guarentee that the nl80211 is available during module init
and allow modules to get their own copy of nl80211 rather than needing
a set function (e.g. netdev_set_nl80211).

Since the dbus name request callback happens before this as well any
dbus module can also use IWD_MODULE and simply assume the dbus object
is ready.

plugin_init was also deferred to nl80211_appeared since some plugins
depend on modules being initialized.
This commit is contained in:
James Prestwood 2019-10-11 12:29:22 -07:00 committed by Denis Kenzior
parent 046fe96537
commit df8fc5f918
1 changed files with 7 additions and 5 deletions

View File

@ -147,6 +147,13 @@ static void nl80211_appeared(const struct l_genl_family_info *info,
l_debug("Found nl80211 interface");
nl80211 = l_genl_family_new(genl, NL80211_GENL_NAME);
if (iwd_modules_init() < 0) {
l_main_quit();
return;
}
plugin_init(plugins, noplugins);
manager_init(nl80211, interfaces, nointerfaces);
anqp_init(nl80211);
@ -482,14 +489,9 @@ int main(int argc, char *argv[])
if (!netdev_init())
goto fail_netdev;
if (iwd_modules_init() < 0)
goto fail_modules;
plugin_init(plugins, noplugins);
exit_status = l_main_run_with_signal(signal_handler, NULL);
plugin_exit();
fail_modules:
iwd_modules_exit();
netdev_exit();
fail_netdev: