From ef209c305b8a3185ca3dd9525599676f1cb43d24 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Thu, 12 Sep 2019 11:12:37 -0700 Subject: [PATCH] knownnetworks: make known frequencies its own module The known frequency file was being loaded at the end of the known networks initialization routine. This allowed all known networks to be properly loaded, but since hotspot depends on known networks, its initalization would be run afterwards meaning the frequency loading would not have been finding any hotspot networks. To fix this a new module was added inside known networks which depends on hotspot. This means that first known networks will initialize, then hotspot, then the frequency file would be loaded. --- src/knownnetworks.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/knownnetworks.c b/src/knownnetworks.c index d9768721..f1d65e6f 100644 --- a/src/knownnetworks.c +++ b/src/knownnetworks.c @@ -781,7 +781,7 @@ static struct network_info *find_network_info_from_path(const char *path) return search.info; } -static void known_network_frequencies_load(void) +static int known_network_frequencies_load(void) { char **groups; struct l_queue *known_frequencies; @@ -790,7 +790,7 @@ static void known_network_frequencies_load(void) known_freqs = storage_known_frequencies_load(); if (!known_freqs) { l_debug("No known frequency file found."); - return; + return 0; } groups = l_settings_get_groups(known_freqs); @@ -822,6 +822,8 @@ next: } l_strv_free(groups); + + return 0; } /* @@ -931,8 +933,6 @@ static int known_networks_init(void) closedir(dir); - known_network_frequencies_load(); - storage_dir_watch = l_dir_watch_new(storage_dir, known_networks_watch_cb, NULL, known_networks_watch_destroy); @@ -950,11 +950,22 @@ static void known_networks_exit(void) l_queue_destroy(known_networks, network_info_free); known_networks = NULL; - l_settings_free(known_freqs); - l_dbus_unregister_interface(dbus, IWD_KNOWN_NETWORK_INTERFACE); watchlist_destroy(&known_network_watches); } IWD_MODULE(known_networks, known_networks_init, known_networks_exit) + +static void known_frequencies_exit(void) +{ + l_settings_free(known_freqs); +} + +/* + * Since the known frequency file should only be read in after all known + * networks are loaded (including hotspots) we need to create another module + * here which depends on hotspot. + */ +IWD_MODULE(known_frequencies, known_network_frequencies_load, known_frequencies_exit) +IWD_MODULE_DEPENDS(known_frequencies, hotspot)