diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2011-12-29 23:16:49 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:14:40 +0100 |
commit | da9d070e8b738519b4828bed5a70d8d27f90acab (patch) | |
tree | f956a823af5875ca97c5b2156a102a0e582ac9f0 | |
parent | 73eeffbd5e388034011e162dd29906e42a0b85a7 (diff) |
iface-modem: don't run signal quality check if last update was less than 15s ago
-rw-r--r-- | src/mm-iface-modem.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 5ab0ccaa..c1ee8b11 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -419,6 +419,20 @@ signal_quality_update_context_free (SignalQualityUpdateContext *ctx) g_free (ctx); } +static time_t +get_last_signal_quality_update_time (MMIfaceModem *self) +{ + SignalQualityUpdateContext *ctx; + + if (G_UNLIKELY (!signal_quality_update_context_quark)) + signal_quality_update_context_quark = (g_quark_from_static_string ( + SIGNAL_QUALITY_UPDATE_CONTEXT_TAG)); + + ctx = g_object_get_qdata (G_OBJECT (self), signal_quality_update_context_quark); + + return (ctx ? ctx->last_update : 0); +} + static gboolean expire_signal_quality (MMIfaceModem *self) { @@ -573,7 +587,10 @@ periodic_signal_quality_check (MMIfaceModem *self) ctx = g_object_get_qdata (G_OBJECT (self), signal_quality_check_context_quark); - if (!ctx->running) { + /* Only launch a new one if not one running already OR if the last one run + * was more than 15s ago. */ + if (!ctx->running || + (time (NULL) - get_last_signal_quality_update_time (self) > 15)) { ctx->running = TRUE; MM_IFACE_MODEM_GET_INTERFACE (self)->load_signal_quality ( self, |