From df8fc5f91857ef0e38ce55f75fdb4f454c92ffa5 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Fri, 11 Oct 2019 12:29:22 -0700 Subject: [PATCH] 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. --- src/main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index b34da3d0..0e6fad14 100644 --- a/src/main.c +++ b/src/main.c @@ -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: