aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2013-04-05 08:54:09 +0200
committerAleksander Morgado <aleksander@lanedo.com>2013-04-05 08:54:09 +0200
commit1cb5831af33237ca8f343410982f44cf8fd2903c (patch)
tree962a31073cc5329f42e873653143651f6c7630f1
parent76ecc1301af4a19d1bef31d320c79edb4ce013a2 (diff)
iface-modem: ensure we cancel the re-initialization idle if the modem goes away
https://bugzilla.gnome.org/show_bug.cgi?id=697290
-rw-r--r--src/mm-iface-modem.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
index b36947f6..83c184d0 100644
--- a/src/mm-iface-modem.c
+++ b/src/mm-iface-modem.c
@@ -36,11 +36,13 @@
#define SIGNAL_QUALITY_UPDATE_CONTEXT_TAG "signal-quality-update-context-tag"
#define SIGNAL_QUALITY_CHECK_CONTEXT_TAG "signal-quality-check-context-tag"
#define ACCESS_TECHNOLOGIES_CHECK_CONTEXT_TAG "access-technologies-check-context-tag"
+#define RESTART_INITIALIZE_IDLE_TAG "restart-initialize-tag"
static GQuark state_update_context_quark;
static GQuark signal_quality_update_context_quark;
static GQuark signal_quality_check_context_quark;
static GQuark access_technologies_check_context_quark;
+static GQuark restart_initialize_idle_quark;
/*****************************************************************************/
@@ -2391,6 +2393,8 @@ reinitialize_ready (MMBaseModem *self,
static gboolean
restart_initialize_idle (MMIfaceModem *self)
{
+ g_object_set_qdata (G_OBJECT (self), restart_initialize_idle_quark, NULL);
+
/* If no wait needed, just go on */
mm_base_modem_initialize (MM_BASE_MODEM (self),
(GAsyncReadyCallback) reinitialize_ready,
@@ -2399,6 +2403,12 @@ restart_initialize_idle (MMIfaceModem *self)
}
static void
+restart_initialize_idle_cancel (gpointer idp)
+{
+ g_source_remove (GPOINTER_TO_UINT (idp));
+}
+
+static void
set_lock_status (MMIfaceModem *self,
MmGdbusModem *skeleton,
MMModemLock lock)
@@ -2420,8 +2430,18 @@ set_lock_status (MMIfaceModem *self,
/* Only restart initialization if leaving LOCKED.
* If this is the case, we do NOT update the state yet, we wait
* to be completely re-initialized to do so. */
- if (old_lock != MM_MODEM_LOCK_UNKNOWN)
- g_idle_add ((GSourceFunc)restart_initialize_idle, self);
+ if (old_lock != MM_MODEM_LOCK_UNKNOWN) {
+ guint id;
+
+ if (G_UNLIKELY (!restart_initialize_idle_quark))
+ restart_initialize_idle_quark = (g_quark_from_static_string (RESTART_INITIALIZE_IDLE_TAG));
+
+ id = g_idle_add ((GSourceFunc)restart_initialize_idle, self);
+ g_object_set_qdata_full (G_OBJECT (self),
+ restart_initialize_idle_quark,
+ GUINT_TO_POINTER (id),
+ (GDestroyNotify)restart_initialize_idle_cancel);
+ }
}
} else {
if (old_lock == MM_MODEM_LOCK_UNKNOWN) {
@@ -4173,6 +4193,12 @@ mm_iface_modem_shutdown (MMIfaceModem *self)
access_technologies_check_context_quark,
NULL);
+ /* Remove running restart initialization idle, if any */
+ if (G_LIKELY (restart_initialize_idle_quark))
+ g_object_set_qdata (G_OBJECT (self),
+ restart_initialize_idle_quark,
+ NULL);
+
/* Remove SIM object */
g_object_set (self,
MM_IFACE_MODEM_SIM, NULL,