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.
This commit is contained in:
Colin Walters 2015-09-01 11:18:54 -04:00 committed by Matthew Barnes
parent 9c0e87bc75
commit da81156d81
3 changed files with 2 additions and 55 deletions

View File

@ -42,12 +42,6 @@ static GOptionEntry opt_entries[] =
static RpmostreedDaemon *rpm_ostree_daemon = NULL; static RpmostreedDaemon *rpm_ostree_daemon = NULL;
static void
on_close (RpmostreedDaemon *daemon, gpointer data)
{
g_main_loop_quit (loop);
}
static void static void
start_daemon (GDBusConnection *connection, start_daemon (GDBusConnection *connection,
gboolean on_messsage_bus) gboolean on_messsage_bus)
@ -66,11 +60,6 @@ start_daemon (GDBusConnection *connection,
g_error ("%s", local_error->message); g_error ("%s", local_error->message);
g_assert_not_reached (); g_assert_not_reached ();
} }
rpmostreed_daemon_hold (rpm_ostree_daemon);
g_signal_connect (rpm_ostree_daemon, "finished",
G_CALLBACK (on_close), NULL);
} }
static void static void
@ -79,8 +68,9 @@ on_bus_acquired (GDBusConnection *connection,
gpointer user_data) gpointer user_data)
{ {
g_debug ("Connected to the system bus"); g_debug ("Connected to the system bus");
}
start_daemon (connection, TRUE);
}
static void static void
on_name_acquired (GDBusConnection *connection, on_name_acquired (GDBusConnection *connection,
@ -88,8 +78,6 @@ on_name_acquired (GDBusConnection *connection,
gpointer user_data) gpointer user_data)
{ {
g_debug ("Acquired the name %s on the system bus", name); g_debug ("Acquired the name %s on the system bus", name);
start_daemon (connection, TRUE);
} }
static void static void
@ -97,17 +85,6 @@ on_name_lost (GDBusConnection *connection,
const char *name, const char *name,
gpointer user_data) 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 static void

View File

@ -33,13 +33,6 @@
* Object holding all global state. * Object holding all global state.
*/ */
enum {
FINISHED,
NUM_SIGNALS
};
static guint signals[NUM_SIGNALS];
typedef struct _RpmostreedDaemonClass RpmostreedDaemonClass; typedef struct _RpmostreedDaemonClass RpmostreedDaemonClass;
/** /**
@ -274,12 +267,6 @@ rpmostreed_daemon_class_init (RpmostreedDaemonClass *klass)
G_PARAM_WRITABLE | G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS)); 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 static void
@ -300,21 +287,6 @@ rpmostreed_daemon_get (void)
return _daemon_instance; 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 void
rpmostreed_daemon_publish (RpmostreedDaemon *self, rpmostreed_daemon_publish (RpmostreedDaemon *self,
const gchar *path, const gchar *path,

View File

@ -29,8 +29,6 @@
GType rpmostreed_daemon_get_type (void) G_GNUC_CONST; GType rpmostreed_daemon_get_type (void) G_GNUC_CONST;
RpmostreedDaemon * rpmostreed_daemon_get (void); RpmostreedDaemon * rpmostreed_daemon_get (void);
void rpmostreed_daemon_hold (RpmostreedDaemon *self);
void rpmostreed_daemon_release (RpmostreedDaemon *self);
void rpmostreed_daemon_publish (RpmostreedDaemon *self, void rpmostreed_daemon_publish (RpmostreedDaemon *self,
const gchar *path, const gchar *path,
gboolean uniquely, gboolean uniquely,