dns: don't let the plugins assert the bus manager has a connection

Make them just ask for connections from GDBus, as other D-Bus clients
do. GDBus anyway reuses the connection if it has one, but allows us to
deal with errors in a more civilized manner.
This commit is contained in:
Lubomir Rintel
2018-07-04 17:55:39 +02:00
parent 89d1c9fb30
commit e1fc005239
2 changed files with 19 additions and 35 deletions

View File

@@ -306,8 +306,6 @@ start_dnsmasq (NMDnsDnsmasq *self)
const char *argv[15];
GPid pid = 0;
guint idx = 0;
NMDBusManager *dbus_mgr;
GDBusConnection *connection;
if (priv->running) {
/* the dnsmasq process is running. Nothing to do. */
@@ -358,22 +356,16 @@ start_dnsmasq (NMDnsDnsmasq *self)
return;
}
dbus_mgr = nm_dbus_manager_get ();
g_return_if_fail (dbus_mgr);
connection = nm_dbus_manager_get_connection (dbus_mgr);
g_return_if_fail (connection);
priv->dnsmasq_cancellable = g_cancellable_new ();
g_dbus_proxy_new (connection,
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
NULL,
DNSMASQ_DBUS_SERVICE,
DNSMASQ_DBUS_PATH,
DNSMASQ_DBUS_SERVICE,
priv->dnsmasq_cancellable,
dnsmasq_proxy_cb,
self);
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
NULL,
DNSMASQ_DBUS_SERVICE,
DNSMASQ_DBUS_PATH,
DNSMASQ_DBUS_SERVICE,
priv->dnsmasq_cancellable,
dnsmasq_proxy_cb,
self);
}
static gboolean

View File

@@ -391,28 +391,20 @@ static void
nm_dns_systemd_resolved_init (NMDnsSystemdResolved *self)
{
NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self);
NMDBusManager *dbus_mgr;
GDBusConnection *connection;
c_list_init (&priv->request_queue_lst_head);
dbus_mgr = nm_dbus_manager_get ();
g_return_if_fail (dbus_mgr);
connection = nm_dbus_manager_get_connection (dbus_mgr);
g_return_if_fail (connection);
priv->init_cancellable = g_cancellable_new ();
g_dbus_proxy_new (connection,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
SYSTEMD_RESOLVED_DBUS_SERVICE,
SYSTEMD_RESOLVED_DBUS_PATH,
SYSTEMD_RESOLVED_DBUS_SERVICE ".Manager",
priv->init_cancellable,
resolved_proxy_created,
self);
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL,
SYSTEMD_RESOLVED_DBUS_SERVICE,
SYSTEMD_RESOLVED_DBUS_PATH,
SYSTEMD_RESOLVED_DBUS_SERVICE ".Manager",
priv->init_cancellable,
resolved_proxy_created,
self);
}
NMDnsPlugin *