dns: fix updating resolv.conf after dnsmasq process dies

When the dnsmasq process dies, two events are generated:

(1) a NM_DNS_PLUGIN_FAILED signal in nm-dns-dnsmasq.c:name_owner_changed()
(2) a NM_DNS_PLUGIN_CHILD_QUIT signal in nm-dns-plugin.c:from watch_cb()

Event (1) is handled by updating resolv.conf with upstream servers,
(2) by restarting the child process.

The order in which the two signals are received is not deterministic,
so when (1) comes after (2) the manager leaves upstream servers in
resolv.conf even if a dnsmasq instance is running.

When dnsmasq disappears from D-Bus and we know that the process is not
running, we should not emit a FAILED signal because the disappearing
is caused by the process termination, and that event is already
handled by the manager.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/105
(cherry picked from commit f2a2012733)
This commit is contained in:
Beniamino Galvani 2019-01-11 15:01:15 +01:00
parent 5a831af656
commit 7a025027a5

View file

@ -254,9 +254,16 @@ name_owner_changed (GObject *object,
priv->running = TRUE;
send_dnsmasq_update (self);
} else {
_LOGI ("dnsmasq disappeared");
priv->running = FALSE;
g_signal_emit_by_name (self, NM_DNS_PLUGIN_FAILED);
if (priv->running) {
_LOGI ("dnsmasq disappeared");
priv->running = FALSE;
g_signal_emit_by_name (self, NM_DNS_PLUGIN_FAILED);
} else {
/* The only reason for which (!priv->running) here
* is that the dnsmasq process quit. We don't care
* of that here, the manager handles child restarts
* by itself. */
}
}
}