core: use nm_utils_get_monotonic_timestamp_s for nm_ap_set_last_seen

https://bugzilla.gnome.org/show_bug.cgi?id=720833

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2013-12-10 16:35:11 +01:00
parent fc870cf110
commit 81aed04da4
3 changed files with 14 additions and 10 deletions

View file

@ -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);

View file

@ -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));

View file

@ -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);