summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDebarshi Ray <debarshir@gnome.org>2015-11-25 18:38:36 +0100
committerDebarshi Ray <debarshir@gnome.org>2015-11-25 19:53:41 +0100
commit37be3d64c9868667f64f8263db50e9cf5f57dde7 (patch)
treeafd5ca85ff4216d8009e1cef507fa2cf6169c41e
parentc242bebc3fe36fe1af31a2606233fda4b3360d38 (diff)
downloadgnome-online-accounts-wip/rishi/ensure-credentials.tar.gz
daemon: Prioritize D-Bus calls over internal oneswip/rishi/ensure-credentials
Unlike internal calls, EnsureCredentials calls received over D-Bus can time out if we don't handle them in time. Also, D-Bus calls are likely to originate from real world applications, while the internal calls are a house keeping activity triggered by potential network changes. https://bugzilla.gnome.org/show_bug.cgi?id=751524
-rw-r--r--src/daemon/goadaemon.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/daemon/goadaemon.c b/src/daemon/goadaemon.c
index f04ef63..e0cf525 100644
--- a/src/daemon/goadaemon.c
+++ b/src/daemon/goadaemon.c
@@ -1233,6 +1233,20 @@ ensure_credentials_queue_collector (GObject *source_object, GAsyncResult *res, g
g_object_unref (task);
}
+static gint
+ensure_credentials_queue_sort (gconstpointer a, gconstpointer b, gpointer user_data)
+{
+ GTask *task_a = G_TASK (a);
+ GTask *task_b = G_TASK (b);
+ gint priority_a;
+ gint priority_b;
+
+ priority_a = g_task_get_priority (task_a);
+ priority_b = g_task_get_priority (task_b);
+
+ return priority_a - priority_b;
+}
+
static void
ensure_credentials_queue_check (GoaDaemon *self)
{
@@ -1249,6 +1263,8 @@ ensure_credentials_queue_check (GoaDaemon *self)
if (self->ensure_credentials_queue->length == 0)
goto out;
+ g_queue_sort (self->ensure_credentials_queue, ensure_credentials_queue_sort, NULL);
+
task = G_TASK (g_queue_peek_head (self->ensure_credentials_queue));
self->ensure_credentials_running = TRUE;
@@ -1307,6 +1323,7 @@ on_account_handle_ensure_credentials (GoaAccount *account,
data = ensure_data_new (object, invocation);
task = g_task_new (self, NULL, NULL, NULL);
+ g_task_set_priority (task, G_PRIORITY_HIGH);
g_task_set_task_data (task, data, (GDestroyNotify) ensure_data_unref);
g_queue_push_tail (self->ensure_credentials_queue, g_object_ref (task));
@@ -1359,6 +1376,7 @@ goa_daemon_check_credentials (GoaDaemon *self)
data = ensure_data_new (object, NULL);
task = g_task_new (self, NULL, NULL, NULL);
+ g_task_set_priority (task, G_PRIORITY_LOW);
g_task_set_task_data (task, data, (GDestroyNotify) ensure_data_unref);
g_queue_push_tail (self->ensure_credentials_queue, g_object_ref (task));