summaryrefslogtreecommitdiff
path: root/src/libaccountsservice/act-user.c
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2017-09-27 14:44:48 -0400
committerRay Strode <rstrode@redhat.com>2017-10-27 13:24:45 -0400
commit3c86a80e2606633da12fb24669dc4d536c708b1c (patch)
treeeca9d6132a820d15c0a0e15c966162e84c45541f /src/libaccountsservice/act-user.c
parentce3f71c806334e0a64222779a128e38c45ec90a6 (diff)
lib: consolidate change notification
if the daemon sends out multiple change notifications for a user because several properties changed in quick succession, try to batch them up, and only update info at the end. https://bugs.freedesktop.org/show_bug.cgi?id=103488
Diffstat (limited to 'src/libaccountsservice/act-user.c')
-rw-r--r--src/libaccountsservice/act-user.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/libaccountsservice/act-user.c b/src/libaccountsservice/act-user.c
index 300118a..d26b46a 100644
--- a/src/libaccountsservice/act-user.c
+++ b/src/libaccountsservice/act-user.c
@@ -140,6 +140,8 @@ struct _ActUser {
guint system_account : 1;
guint local_account : 1;
guint nonexistent : 1;
+
+ guint update_info_timeout_id;
};
struct _ActUserClass
@@ -600,6 +602,10 @@ act_user_finalize (GObject *object)
g_object_unref (user->connection);
}
+ if (user->update_info_timeout_id != 0) {
+ g_source_remove (user->update_info_timeout_id);
+ }
+
if (G_OBJECT_CLASS (act_user_parent_class)->finalize)
(*G_OBJECT_CLASS (act_user_parent_class)->finalize) (object);
}
@@ -1366,13 +1372,25 @@ update_info (ActUser *user)
user);
}
+static gboolean
+on_timeout_update_info (ActUser *user)
+{
+ update_info (user);
+ user->update_info_timeout_id = 0;
+
+ return G_SOURCE_REMOVE;
+}
+
static void
changed_handler (AccountsUser *object,
gpointer *data)
{
ActUser *user = ACT_USER (data);
- update_info (user);
+ if (user->update_info_timeout_id != 0)
+ return;
+
+ user->update_info_timeout_id = g_timeout_add (250, (GSourceFunc) on_timeout_update_info, user);
}
/**