aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIain Lane <iain.lane@canonical.com>2015-09-01 10:25:41 +0100
committerIain Lane <iain.lane@canonical.com>2015-09-01 10:25:41 +0100
commitf016debfbaac39f509f5947b098c141a03a3b65f (patch)
tree4ee7b0bd8c523399b962ea2405ac28d7698a3d5c /src
parent132ac93bbd4141824cfa22f6516366f953fce9a0 (diff)
downloadayatana-indicator-datetime-f016debfbaac39f509f5947b098c141a03a3b65f.tar.gz
ayatana-indicator-datetime-f016debfbaac39f509f5947b098c141a03a3b65f.tar.bz2
ayatana-indicator-datetime-f016debfbaac39f509f5947b098c141a03a3b65f.zip
Add a timeout so we can't hang forever
Diffstat (limited to 'src')
-rw-r--r--src/timezone-file.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/timezone-file.cpp b/src/timezone-file.cpp
index 15e4f61..ef9d78a 100644
--- a/src/timezone-file.cpp
+++ b/src/timezone-file.cpp
@@ -64,6 +64,12 @@ private:
m_properties_changed_id = 0;
}
+ if (m_timeout_id)
+ {
+ g_source_remove(m_timeout_id);
+ m_timeout_id = 0;
+ }
+
g_clear_object(&m_proxy);
g_clear_pointer(&m_loop, g_main_loop_unref);
}
@@ -124,6 +130,12 @@ out:
g_clear_pointer(&prop, g_variant_unref);
if (self->m_loop && g_main_loop_is_running(self->m_loop))
g_main_loop_quit(self->m_loop);
+
+ if (self->m_timeout_id)
+ {
+ g_source_remove(self->m_timeout_id);
+ self->m_timeout_id = 0;
+ }
}
static void on_name_appeared(GDBusConnection *connection,
@@ -143,6 +155,20 @@ out:
gself);
}
+ static gboolean quit_loop(gpointer gself)
+ {
+ auto self = static_cast<Impl*>(gself);
+
+ g_warning("Timed out when getting initial value of timezone, defaulting to UTC");
+ self->notify_timezone("Etc/Utc");
+
+ g_main_loop_quit(self->m_loop);
+
+ self->m_timeout_id = 0;
+
+ return G_SOURCE_REMOVE;
+ }
+
static void on_name_vanished(GDBusConnection *connection G_GNUC_UNUSED,
const gchar *name G_GNUC_UNUSED,
gpointer gself)
@@ -167,6 +193,8 @@ out:
this,
nullptr);
+ /* Incase something breaks, we don't want to hang */
+ m_timeout_id = g_timeout_add(500, quit_loop, this);
g_main_loop_run(m_loop);
}
@@ -183,6 +211,7 @@ out:
FileTimezone & m_owner;
unsigned long m_properties_changed_id = 0;
unsigned long m_bus_watch_id = 0;
+ unsigned long m_timeout_id = 0;
GDBusProxy *m_proxy = nullptr;
GMainLoop *m_loop = nullptr;
};