From da81156d819d37381949f6449392933e9a79784f Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 1 Sep 2015 11:18:54 -0400 Subject: [PATCH] daemon: Export objects on bus (not name) acquision This closes a race condition where the objects might not be exported by the time clients call methods. Also delete the code in the "on name lost" handler - it's not going to happen in practice (we don't allow replacement), and causes issues as it may be run first before we get the notification that the name is owned. github.com/cockpit-project/storaged has some better code here which we could copy later. This then in turn allows us to delete the "hold"/"release" infrastructure. Basically the daemon will live forever in the process. --- src/daemon/main.c | 27 ++------------------------- src/daemon/rpmostreed-daemon.c | 28 ---------------------------- src/daemon/rpmostreed-daemon.h | 2 -- 3 files changed, 2 insertions(+), 55 deletions(-) diff --git a/src/daemon/main.c b/src/daemon/main.c index d90d336e..e5b07e72 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -42,12 +42,6 @@ static GOptionEntry opt_entries[] = static RpmostreedDaemon *rpm_ostree_daemon = NULL; -static void -on_close (RpmostreedDaemon *daemon, gpointer data) -{ - g_main_loop_quit (loop); -} - static void start_daemon (GDBusConnection *connection, gboolean on_messsage_bus) @@ -66,11 +60,6 @@ start_daemon (GDBusConnection *connection, g_error ("%s", local_error->message); g_assert_not_reached (); } - - rpmostreed_daemon_hold (rpm_ostree_daemon); - - g_signal_connect (rpm_ostree_daemon, "finished", - G_CALLBACK (on_close), NULL); } static void @@ -79,8 +68,9 @@ on_bus_acquired (GDBusConnection *connection, gpointer user_data) { g_debug ("Connected to the system bus"); -} + start_daemon (connection, TRUE); +} static void on_name_acquired (GDBusConnection *connection, @@ -88,8 +78,6 @@ on_name_acquired (GDBusConnection *connection, gpointer user_data) { g_debug ("Acquired the name %s on the system bus", name); - - start_daemon (connection, TRUE); } static void @@ -97,17 +85,6 @@ on_name_lost (GDBusConnection *connection, const char *name, gpointer user_data) { - g_critical ("Lost (or failed to acquire) the " - "name %s on the system bus", name); - - if (rpm_ostree_daemon == NULL) - { - g_main_loop_quit (loop); - } - else - { - rpmostreed_daemon_release (rpm_ostree_daemon); - } } static void diff --git a/src/daemon/rpmostreed-daemon.c b/src/daemon/rpmostreed-daemon.c index 8cf911a2..5bcf8fac 100644 --- a/src/daemon/rpmostreed-daemon.c +++ b/src/daemon/rpmostreed-daemon.c @@ -33,13 +33,6 @@ * Object holding all global state. */ -enum { - FINISHED, - NUM_SIGNALS -}; - -static guint signals[NUM_SIGNALS]; - typedef struct _RpmostreedDaemonClass RpmostreedDaemonClass; /** @@ -274,12 +267,6 @@ rpmostreed_daemon_class_init (RpmostreedDaemonClass *klass) G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); - - signals[FINISHED] = g_signal_new ("finished", - RPMOSTREED_TYPE_DAEMON, - G_SIGNAL_RUN_LAST, - 0, NULL, NULL, NULL, - G_TYPE_NONE, 0); } static void @@ -300,21 +287,6 @@ rpmostreed_daemon_get (void) return _daemon_instance; } -void -rpmostreed_daemon_hold (RpmostreedDaemon *self) -{ - self->use_count++; -} - -void -rpmostreed_daemon_release (RpmostreedDaemon *self) -{ - self->use_count--; - - if (self->use_count == 0) - g_signal_emit (self, signals[FINISHED], 0); -} - void rpmostreed_daemon_publish (RpmostreedDaemon *self, const gchar *path, diff --git a/src/daemon/rpmostreed-daemon.h b/src/daemon/rpmostreed-daemon.h index bd946005..8dbb08c0 100644 --- a/src/daemon/rpmostreed-daemon.h +++ b/src/daemon/rpmostreed-daemon.h @@ -29,8 +29,6 @@ GType rpmostreed_daemon_get_type (void) G_GNUC_CONST; RpmostreedDaemon * rpmostreed_daemon_get (void); -void rpmostreed_daemon_hold (RpmostreedDaemon *self); -void rpmostreed_daemon_release (RpmostreedDaemon *self); void rpmostreed_daemon_publish (RpmostreedDaemon *self, const gchar *path, gboolean uniquely,