diff options
author | Ray Strode <rstrode@redhat.com> | 2011-03-10 09:36:30 -0500 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2011-03-10 09:36:30 -0500 |
commit | 2c3188abc3395aedd20eab36c6d3a7b767cc8804 (patch) | |
tree | 1380760aa3ebcb6d867542ac8647513cfec7539b /src | |
parent | 9f0963c1f1cae85da2d426af55756dffeead9ce0 (diff) |
lib: gracefully handle multiple in-flight user updates
Previously, the second update would overwrite the first update's
state, and when the first update's completion handler finished
things would blow up.
Diffstat (limited to 'src')
-rw-r--r-- | src/libaccountsservice/act-user.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/libaccountsservice/act-user.c b/src/libaccountsservice/act-user.c index cbbdb3b..afaf43d 100644 --- a/src/libaccountsservice/act-user.c +++ b/src/libaccountsservice/act-user.c @@ -1019,6 +1019,7 @@ on_get_all_finished (DBusGProxy *proxy, gboolean res; g_assert (user->get_all_call == call); + g_assert (DBUS_IS_G_PROXY (user->object_proxy)); g_assert (user->object_proxy == proxy); error = NULL; @@ -1029,13 +1030,12 @@ on_get_all_finished (DBusGProxy *proxy, &hash_table, G_TYPE_INVALID); user->get_all_call = NULL; - user->object_proxy = NULL; if (! res) { g_debug ("Error calling GetAll() when retrieving properties for %s: %s", user->object_path, error->message); g_error_free (error); - goto out; + return; } g_hash_table_foreach (hash_table, (GHFunc) collect_props, user); g_hash_table_unref (hash_table); @@ -1045,23 +1045,16 @@ on_get_all_finished (DBusGProxy *proxy, } g_signal_emit (user, signals[CHANGED], 0); - -out: - g_object_unref (proxy); } static gboolean update_info (ActUser *user) { - DBusGProxy *proxy; DBusGProxyCall *call; - proxy = dbus_g_proxy_new_for_name (user->connection, - ACCOUNTS_NAME, - user->object_path, - DBUS_INTERFACE_PROPERTIES); + g_assert (DBUS_IS_G_PROXY (user->object_proxy)); - call = dbus_g_proxy_begin_call (proxy, + call = dbus_g_proxy_begin_call (user->object_proxy, "GetAll", (DBusGProxyCallNotify) on_get_all_finished, @@ -1076,15 +1069,14 @@ update_info (ActUser *user) goto failed; } + if (user->get_all_call != NULL) { + dbus_g_proxy_cancel_call (user->object_proxy, user->get_all_call); + } + user->get_all_call = call; - user->object_proxy = proxy; return TRUE; failed: - if (proxy != NULL) { - g_object_unref (proxy); - } - return FALSE; } @@ -1125,6 +1117,11 @@ _act_user_update_from_object_path (ActUser *user, dbus_g_proxy_connect_signal (user->accounts_proxy, "Changed", G_CALLBACK (changed_handler), user, NULL); + user->object_proxy = dbus_g_proxy_new_for_name (user->connection, + ACCOUNTS_NAME, + user->object_path, + DBUS_INTERFACE_PROPERTIES); + if (!update_info (user)) { g_warning ("Couldn't update info for user with object path %s", object_path); } |