[accountsservice/f15/master] lib: gracefully handle multiple in-flight user updates

Ray Strode rstrode at fedoraproject.org
Thu Mar 10 18:42:23 UTC 2011


commit ef5bf65871045090b72e3174781868a46b9ad7d9
Author: Ray Strode <rstrode at redhat.com>
Date:   Thu Mar 10 13:42:02 2011 -0500

    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.

 accountsservice.spec    |    8 +++-
 fix-get-all-crash.patch |  100 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 107 insertions(+), 1 deletions(-)
---
diff --git a/accountsservice.spec b/accountsservice.spec
index 1a6a7a1..1b2991f 100644
--- a/accountsservice.spec
+++ b/accountsservice.spec
@@ -1,7 +1,7 @@
 
 Name:           accountsservice
 Version:        0.6.5
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        D-Bus interfaces for querying and manipulating user account information
 
 Group:          System Environment/Daemons
@@ -21,6 +21,8 @@ Requires:       polkit
 Requires:       ConsoleKit
 Requires:       shadow-utils
 
+Patch0: fix-get-all-crash.patch
+
 %package libs
 Summary: Client-side library to talk to accountservice
 Group: Development/Libraries
@@ -50,6 +52,7 @@ of these interfaces, based on the useradd, usermod and userdel commands.
 
 %prep
 %setup -q
+%patch0 -p1 -b .fix-get-all-crash
 
 %build
 %configure
@@ -88,6 +91,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.a
 %{_datadir}/gir-1.0/AccountsService-1.0.gir
 
 %changelog
+* Thu Mar 10 2011 Ray Strode <rstrode at redhat.com> 0.6.5-2
+- Fix crash reported on #gnome-hackers this morning
+
 * Tue Mar 08 2011 Ray Strode <rstrode at redhat.com> 0.6.5-1
 - Update to 0.6.5
 
diff --git a/fix-get-all-crash.patch b/fix-get-all-crash.patch
new file mode 100644
index 0000000..436a6a3
--- /dev/null
+++ b/fix-get-all-crash.patch
@@ -0,0 +1,100 @@
+From 2c3188abc3395aedd20eab36c6d3a7b767cc8804 Mon Sep 17 00:00:00 2001
+From: Ray Strode <rstrode at redhat.com>
+Date: Thu, 10 Mar 2011 09:36:30 -0500
+Subject: [PATCH] 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.
+---
+ 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);
+         }
+-- 
+1.7.4.1
+


More information about the scm-commits mailing list