3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-29 13:59:24 +01:00

knownneetworks: React to mtime updates

We track mtime as the 'LastConnectedTime' of the network, and also sort
the known network list according to the last connected time.
Unfortunately we were never reacting to ATTRIB changes, and so were
never updating the network_info->connected_time whenever a network was
connected to.

Rework the logic to address this.  This also fixes a small bug where the
connected_time was not set properly prior to removal / re-insertion of
the network_info.
This commit is contained in:
Denis Kenzior 2020-01-27 14:28:08 -06:00
parent f2af2d004d
commit 03ccc454b7
3 changed files with 45 additions and 20 deletions

View File

@ -460,12 +460,24 @@ static void hs20_dir_watch_cb(const char *filename,
return;
}
known_network_update(&config->super, new, connected_time);
known_network_set_connected_time(&config->super,
connected_time);
known_network_update(&config->super, new);
l_settings_free(new);
break;
case L_DIR_WATCH_EVENT_ACCESSED:
break;
case L_DIR_WATCH_EVENT_ATTRIB:
config = l_queue_find(hs20_settings, match_filename, full_path);
if (!config)
return;
connected_time = l_path_get_mtime(full_path);
known_network_set_connected_time(&config->super,
connected_time);
break;
}
}

View File

@ -335,25 +335,28 @@ bool network_info_match_nai_realm(const struct network_info *info,
return info->ops->match_nai_realms(info, nai_realms);
}
void known_network_update(struct network_info *network,
struct l_settings *settings,
void known_network_set_connected_time(struct network_info *network,
uint64_t connected_time)
{
bool is_hidden;
bool is_autoconnectable;
if (network->connected_time == connected_time)
return;
network->connected_time = connected_time;
if (network->connected_time != connected_time) {
l_dbus_property_changed(dbus_get_bus(),
known_network_get_path(network),
IWD_KNOWN_NETWORK_INTERFACE,
"LastConnectedTime");
l_queue_remove(known_networks, network);
l_queue_insert(known_networks, network, connected_time_compare,
NULL);
}
l_queue_insert(known_networks, network, connected_time_compare, NULL);
}
network->connected_time = connected_time;
void known_network_update(struct network_info *network,
struct l_settings *settings)
{
bool is_hidden;
bool is_autoconnectable;
if (!l_settings_get_bool(settings, "Settings", "Hidden", &is_hidden))
is_hidden = false;
@ -753,10 +756,11 @@ static void known_networks_watch_cb(const char *filename,
if (settings) {
connected_time = l_path_get_mtime(full_path);
if (network_before)
known_network_update(network_before, settings,
if (network_before) {
known_network_set_connected_time(network_before,
connected_time);
else
known_network_update(network_before, settings);
} else
known_network_new(ssid, security, settings,
connected_time);
} else if (network_before)
@ -766,6 +770,14 @@ static void known_networks_watch_cb(const char *filename,
break;
case L_DIR_WATCH_EVENT_ACCESSED:
break;
case L_DIR_WATCH_EVENT_ATTRIB:
if (network_before) {
connected_time = l_path_get_mtime(full_path);
known_network_set_connected_time(network_before,
connected_time);
}
break;
}
}

View File

@ -125,6 +125,7 @@ bool network_info_match_nai_realm(const struct network_info *info,
void known_networks_add(struct network_info *info);
void known_network_update(struct network_info *info,
struct l_settings *settings,
struct l_settings *settings);
void known_network_set_connected_time(struct network_info *network,
uint64_t connected_time);
void known_networks_remove(struct network_info *info);