From e6b47236f00ab91056be9fc3f9b8611fb16d9e57 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 15 Jan 2015 11:38:33 -0600 Subject: [PATCH 4/4] dns: refresh DNS if plugin child quits unexpectedly (bgo #728342) 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 (cherry picked from commit 09a05f6c3e0b4502252d70cb121654e7312520c5) --- src/dns-manager/nm-dns-manager.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c index e833ce4..c81bfd6 100644 --- a/src/dns-manager/nm-dns-manager.c +++ b/src/dns-manager/nm-dns-manager.c @@ -823,6 +823,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, @@ -1139,6 +1155,7 @@ nm_dns_manager_init (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); } } @@ -1149,7 +1166,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 -- 2.4.0