diff --git a/src/devices/nm-device-wifi.c b/src/devices/nm-device-wifi.c index e91214e16..6b47225fb 100644 --- a/src/devices/nm-device-wifi.c +++ b/src/devices/nm-device-wifi.c @@ -1438,7 +1438,7 @@ impl_device_request_scan (NMDeviceWifi *self, { NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); NMDevice *device = NM_DEVICE (self); - time_t last_scan; + gint32 last_scan; GError *error; if ( !priv->enabled @@ -1459,7 +1459,7 @@ impl_device_request_scan (NMDeviceWifi *self, } last_scan = nm_supplicant_interface_get_last_scan_time (priv->supplicant.iface); - if ((time (NULL) - last_scan) < 10) { + if (last_scan && (nm_utils_get_monotonic_timestamp_s () - last_scan) < 10) { error = g_error_new_literal (NM_WIFI_ERROR, NM_WIFI_ERROR_SCAN_NOT_ALLOWED, "Scanning not allowed immediately following previous scan"); diff --git a/src/supplicant-manager/nm-supplicant-interface.c b/src/supplicant-manager/nm-supplicant-interface.c index 4063085c3..789039c7a 100644 --- a/src/supplicant-manager/nm-supplicant-interface.c +++ b/src/supplicant-manager/nm-supplicant-interface.c @@ -24,6 +24,7 @@ #include #include +#include "NetworkManagerUtils.h" #include "nm-supplicant-interface.h" #include "nm-supplicant-manager.h" #include "nm-logging.h" @@ -106,7 +107,7 @@ typedef struct { guint32 blobs_left; GHashTable * bss_proxies; - time_t last_scan; + gint32 last_scan; /* timestamp as returned by nm_utils_get_monotonic_timestamp_s() */ NMSupplicantConfig * cfg; @@ -167,7 +168,7 @@ bss_properties_changed (DBusGProxy *proxy, NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); if (priv->scanning) - priv->last_scan = time (NULL); + priv->last_scan = nm_utils_get_monotonic_timestamp_s (); if (g_strcmp0 (interface, WPAS_DBUS_IFACE_BSS) == 0) g_signal_emit (self, signals[BSS_UPDATED], 0, dbus_g_proxy_get_path (proxy), props); @@ -230,7 +231,7 @@ wpas_iface_bss_added (DBusGProxy *proxy, NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); if (priv->scanning) - priv->last_scan = time (NULL); + priv->last_scan = nm_utils_get_monotonic_timestamp_s (); handle_new_bss (self, object_path, props); } @@ -334,7 +335,7 @@ set_state (NMSupplicantInterface *self, guint32 new_state) if ( priv->state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING || old_state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING) - priv->last_scan = time (NULL); + priv->last_scan = nm_utils_get_monotonic_timestamp_s (); /* Disconnect reason is no longer relevant when not in the DISCONNECTED state */ if (priv->state != NM_SUPPLICANT_INTERFACE_STATE_DISCONNECTED) @@ -367,7 +368,7 @@ set_scanning (NMSupplicantInterface *self, gboolean new_scanning) /* Cache time of last scan completion */ if (priv->scanning == FALSE) - priv->last_scan = time (NULL); + priv->last_scan = nm_utils_get_monotonic_timestamp_s (); g_object_notify (G_OBJECT (self), "scanning"); } @@ -388,7 +389,7 @@ nm_supplicant_interface_get_scanning (NMSupplicantInterface *self) return FALSE; } -time_t +gint32 nm_supplicant_interface_get_last_scan_time (NMSupplicantInterface *self) { return NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self)->last_scan; @@ -403,7 +404,7 @@ wpas_iface_scan_done (DBusGProxy *proxy, NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); /* Cache last scan completed time */ - priv->last_scan = time (NULL); + priv->last_scan = nm_utils_get_monotonic_timestamp_s (); g_signal_emit (self, signals[SCAN_DONE], 0, success); } diff --git a/src/supplicant-manager/nm-supplicant-interface.h b/src/supplicant-manager/nm-supplicant-interface.h index 2f0233cf7..633c16cc5 100644 --- a/src/supplicant-manager/nm-supplicant-interface.h +++ b/src/supplicant-manager/nm-supplicant-interface.h @@ -144,7 +144,7 @@ const char *nm_supplicant_interface_state_to_string (guint32 state); gboolean nm_supplicant_interface_get_scanning (NMSupplicantInterface *self); -time_t nm_supplicant_interface_get_last_scan_time (NMSupplicantInterface *self); +gint32 nm_supplicant_interface_get_last_scan_time (NMSupplicantInterface *self); const char *nm_supplicant_interface_get_ifname (NMSupplicantInterface *self);