summaryrefslogtreecommitdiffstats
path: root/src/ck-manager.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-07-27 18:16:15 +0200
committerLennart Poettering <lennart@poettering.net>2009-08-12 03:54:03 +0200
commit8535db29009c48a37fc2559ca0fcc5b366e1e122 (patch)
tree3b32b49ee638c7c62fed253471757f9bc906ca3d /src/ck-manager.c
parent17fe9ecafedffde111fd0ac95d5688bf5a330972 (diff)
database: write the console database to disk before signalling via dbus
We simply change the order how the signal handlers for D-Bus and the database dumping are registered. According to the gobject docs it is guaranteed that the signal handlers are run in the same order as they are registered, so this should be safe and have the desired effect.
Diffstat (limited to 'src/ck-manager.c')
-rw-r--r--src/ck-manager.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/ck-manager.c b/src/ck-manager.c
index d5d2c65..440163b 100644
--- a/src/ck-manager.c
+++ b/src/ck-manager.c
@@ -1304,13 +1304,21 @@ add_new_seat (CkManager *manager,
sid = generate_seat_id (manager);
seat = ck_seat_new (sid, kind);
- if (seat == NULL) {
- /* returns null if connection to bus fails */
- g_free (sid);
- goto out;
- }
+
+ /* First we connect our own signals to the seat, followed by
+ * the D-Bus signal hookup to make sure we can first dump the
+ * database and only then send out the D-Bus signals for
+ * it. GObject guarantees us that the signal handlers are
+ * called in the same order as they are registered. */
connect_seat_signals (manager, seat);
+ if (!ck_seat_register (seat)) {
+ /* returns false if connection to bus fails */
+ disconnect_seat_signals (manager, seat);
+ g_object_unref (seat);
+ g_free (sid);
+ return NULL;
+ }
g_hash_table_insert (manager->priv->seats, sid, seat);
@@ -1322,7 +1330,6 @@ add_new_seat (CkManager *manager,
log_seat_added_event (manager, seat);
- out:
return seat;
}
@@ -2407,14 +2414,16 @@ add_seat_for_file (CkManager *manager,
sid = generate_seat_id (manager);
seat = ck_seat_new_from_file (sid, filename);
- if (seat == NULL) {
- /* returns null if connection to bus fails */
+
+ connect_seat_signals (manager, seat);
+ if (!ck_seat_register (seat)) {
+ /* returns false if connection to bus fails */
+ disconnect_seat_signals (manager, seat);
+ g_object_unref (seat);
g_free (sid);
return;
}
- connect_seat_signals (manager, seat);
-
g_hash_table_insert (manager->priv->seats, sid, seat);
g_debug ("Added seat: %s", sid);