diff --git a/src/devices/nm-device-wifi.c b/src/devices/nm-device-wifi.c index 2db8b419bd..c1102bf303 100644 --- a/src/devices/nm-device-wifi.c +++ b/src/devices/nm-device-wifi.c @@ -1897,7 +1897,7 @@ static gboolean cull_scan_list (NMDeviceWifi *self) { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - time_t now = time (NULL); + gint32 now = nm_utils_get_monotonic_timestamp_s (); GSList *outdated_list = NULL; GSList *elt; guint32 removed = 0, total = 0; @@ -1913,6 +1913,7 @@ cull_scan_list (NMDeviceWifi *self) for (elt = priv->ap_list; elt; elt = g_slist_next (elt), total++) { NMAccessPoint *ap = elt->data; const guint prune_interval_s = SCAN_INTERVAL_MAX * 3; + gint32 last_seen; /* Don't cull the associated AP or manually created APs */ if (ap == priv->current_ap) @@ -1930,7 +1931,8 @@ cull_scan_list (NMDeviceWifi *self) && g_object_get_data (G_OBJECT (ap), WPAS_REMOVED_TAG) == NULL) continue; - if (nm_ap_get_last_seen (ap) + prune_interval_s < now) + last_seen = nm_ap_get_last_seen (ap); + if (!last_seen || last_seen + prune_interval_s < now) outdated_list = g_slist_prepend (outdated_list, ap); } @@ -2036,7 +2038,7 @@ supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface, /* Update the AP's last-seen property */ ap = get_ap_by_supplicant_path (self, object_path); if (ap) - nm_ap_set_last_seen (ap, (guint32) time (NULL)); + nm_ap_set_last_seen (ap, nm_utils_get_monotonic_timestamp_s ()); /* Remove outdated access points */ schedule_scanlist_cull (self); diff --git a/src/nm-wifi-ap.c b/src/nm-wifi-ap.c index b7af653289..c68d808c17 100644 --- a/src/nm-wifi-ap.c +++ b/src/nm-wifi-ap.c @@ -59,7 +59,7 @@ typedef struct gboolean fake; /* Whether or not the AP is from a scan */ gboolean hotspot; /* Whether the AP is a local device's hotspot network */ gboolean broadcast; /* Whether or not the AP is broadcasting (hidden) */ - glong last_seen; /* Last time the AP was seen in a scan in seconds */ + gint32 last_seen; /* Timestamp when the AP was seen lastly (obtained via nm_utils_get_monotonic_timestamp_s()) */ } NMAccessPointPrivate; #define NM_AP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_AP, NMAccessPointPrivate)) @@ -504,7 +504,7 @@ nm_ap_new_from_properties (const char *supplicant_path, GHashTable *properties) return NULL; } - nm_ap_set_last_seen (ap, (guint32) time (NULL)); + nm_ap_set_last_seen (ap, nm_utils_get_monotonic_timestamp_s ()); if (!nm_ap_get_ssid (ap)) nm_ap_set_broadcast (ap, FALSE); @@ -745,7 +745,7 @@ nm_ap_dump (NMAccessPoint *ap, const char *prefix) nm_log_dbg (LOGD_WIFI_SCAN, " quality %d", priv->strength); nm_log_dbg (LOGD_WIFI_SCAN, " frequency %d", priv->freq); nm_log_dbg (LOGD_WIFI_SCAN, " max rate %d", priv->max_bitrate); - nm_log_dbg (LOGD_WIFI_SCAN, " last-seen %ld", priv->last_seen); + nm_log_dbg (LOGD_WIFI_SCAN, " last-seen %d", (int) priv->last_seen); } const char * @@ -1095,14 +1095,16 @@ void nm_ap_set_broadcast (NMAccessPoint *ap, gboolean broadcast) * APs older than a certain date are dropped from the list. * */ -glong nm_ap_get_last_seen (const NMAccessPoint *ap) +gint32 +nm_ap_get_last_seen (const NMAccessPoint *ap) { g_return_val_if_fail (NM_IS_AP (ap), FALSE); return NM_AP_GET_PRIVATE (ap)->last_seen; } -void nm_ap_set_last_seen (NMAccessPoint *ap, const glong last_seen) +void +nm_ap_set_last_seen (NMAccessPoint *ap, gint32 last_seen) { g_return_if_fail (NM_IS_AP (ap)); diff --git a/src/nm-wifi-ap.h b/src/nm-wifi-ap.h index be650f6c28..f51fa078ee 100644 --- a/src/nm-wifi-ap.h +++ b/src/nm-wifi-ap.h @@ -101,8 +101,8 @@ void nm_ap_set_fake (NMAccessPoint *ap, gboolean fake); gboolean nm_ap_get_broadcast (NMAccessPoint *ap); void nm_ap_set_broadcast (NMAccessPoint *ap, gboolean broadcast); -glong nm_ap_get_last_seen (const NMAccessPoint *ap); -void nm_ap_set_last_seen (NMAccessPoint *ap, const glong last_seen); +gint32 nm_ap_get_last_seen (const NMAccessPoint *ap); +void nm_ap_set_last_seen (NMAccessPoint *ap, gint32 last_seen); gboolean nm_ap_check_compatible (NMAccessPoint *self, NMConnection *connection);