From 8bbd9ed42847fc8f301fc3302b248979b9729bee Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 5 Sep 2014 15:49:12 +0300 Subject: [PATCH] core: Fix concurrent authorizations In case multiple authorizations happen it can trigger a second call to agent_authorize_service while the first is still ongoing causing all authorization to fail. --- src/adapter.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index f9c58afc5..2192e906f 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -4964,6 +4964,16 @@ static void agent_auth_cb(struct agent *agent, DBusError *derr, g_free(auth); + /* Stop processing if queue is empty */ + if (g_queue_is_empty(adapter->auths)) { + if (adapter->auth_idle_id > 0) + g_source_remove(adapter->auth_idle_id); + return; + } + + if (adapter->auth_idle_id > 0) + return; + adapter->auth_idle_id = g_idle_add(process_auth_queue, adapter); } @@ -4991,6 +5001,10 @@ static gboolean process_auth_queue(gpointer user_data) goto next; } + /* If agent is set authorization is already ongoing */ + if (auth->agent) + return FALSE; + auth->agent = agent_get(NULL); if (auth->agent == NULL) { warn("Authentication attempt without agent"); -- 2.47.3