diff options
author | Dan Williams <dcbw@redhat.com> | 2015-01-15 11:38:33 -0600 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2015-03-09 11:02:42 -0500 |
commit | 12fc01b0bd0645016800c2430d04447edf8220b5 (patch) | |
tree | 00ed23c904fd63135fc4978a238faaa5620c17b2 | |
parent | 5a9fac4b91797a5c6c2a117e2691f4e4085b571f (diff) | |
download | NetworkManager-12fc01b0bd0645016800c2430d04447edf8220b5.tar.gz |
dns: refresh DNS if plugin child quits unexpectedly (bgo #728342)dcbw/dns-plugin-children-bgo728342
If the child dies, or something kills the child externally, refresh
DNS which should respawn the child, similar to what we do with
wpa_supplicant, teamd, etc.
https://bugzilla.gnome.org/show_bug.cgi?id=728342
-rw-r--r-- | src/dns-manager/nm-dns-manager.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c index 3dcc6da633..5d305743f3 100644 --- a/src/dns-manager/nm-dns-manager.c +++ b/src/dns-manager/nm-dns-manager.c @@ -847,6 +847,22 @@ plugin_failed (NMDnsPlugin *plugin, gpointer user_data) } } +static void +plugin_child_quit (NMDnsPlugin *plugin, int exit_status, gpointer user_data) +{ + NMDnsManager *self = NM_DNS_MANAGER (user_data); + GError *error = NULL; + + nm_log_warn (LOGD_DNS, "DNS: plugin %s child quit unexpectedly; refreshing DNS", + nm_dns_plugin_get_name (plugin)); + + /* Let the plugin try to spawn the child again */ + if (!update_dns (self, FALSE, &error)) { + nm_log_warn (LOGD_DNS, "could not commit DNS changes: %s", error->message); + g_clear_error (&error); + } +} + gboolean nm_dns_manager_add_ip4_config (NMDnsManager *mgr, const char *iface, @@ -1132,6 +1148,7 @@ init_resolv_conf_mode (NMDnsManager *self) if (priv->plugin) { nm_log_info (LOGD_DNS, "DNS: loaded plugin %s", nm_dns_plugin_get_name (priv->plugin)); g_signal_connect (priv->plugin, NM_DNS_PLUGIN_FAILED, G_CALLBACK (plugin_failed), self); + g_signal_connect (priv->plugin, NM_DNS_PLUGIN_CHILD_QUIT, G_CALLBACK (plugin_child_quit), self); } } @@ -1177,7 +1194,11 @@ dispose (GObject *object) NMDnsManagerPrivate *priv = NM_DNS_MANAGER_GET_PRIVATE (self); GError *error = NULL; - g_clear_object (&priv->plugin); + if (priv->plugin) { + g_signal_handlers_disconnect_by_func (priv->plugin, plugin_failed, self); + g_signal_handlers_disconnect_by_func (priv->plugin, plugin_child_quit, self); + g_clear_object (&priv->plugin); + } /* If we're quitting, leave a valid resolv.conf in place, not one * pointing to 127.0.0.1 if any plugins were active. Thus update |