NetworkManager/shared
Thomas Haller a780b04837 dns/dnsmasq: refactor tracking of dnsmasq process
Several points.

- We spawn the dnsmasq process directly. That has several downsides:

  - The lifetime of the process is tied to NetworkManager's. When
    stopping NetworkManager, we usually also stop dnsmasq. Or we keep
    the process running, but later the process is no longer a child process
    of NetworkManager and we can only kill it using the pidfile.

  - We don't do special sandboxing of the dnsmasq process.

- Note that we want to ensure that only one dnsmasq process is running
at any time. We should track that in a singletone. Note that NMDnsDnsmasq
is not a singleton. While there is only one instance active at any time,
the DNS plugin can be swapped (e.g. during SIGHUP). Hence, don't track the
process per-NMDnsDnsmasq instance, but in a global variable "gl_pid".

- Usually, when NetworkManager quits, it also stops the dnsmasq process.
Previously, we would always try to terminate the process based on the
pidfile. That is wrong. Most of the time, NetworkManager spawned the
process itself, as a child process. Hence, the PID is known and NetworkManager
will get a signal when dnsmasq exits. The only moment when NetworkManager should
use the pidfile, is the first time when checking to kill the previous instance.
That is: only once at the beginning, to kill instances that were
intentionally or unintentionally (crash) left running earlier.
This is now done by _gl_pid_kill_external().

- Previously, before starting a new dnsmasq instance we would kill a
possibly already running one, and block while waiting for the process to
disappear. We should never block. Especially, since we afterwards start
the process also in non-blocking way, there is no reason to kill the
existing process in a blocking way. For the most part, starting dnsmasq
is already asynchronous and so should be the killing of the dnsmasq
process.

- Drop GDBusProxy and only use GDBusConnection. It fully suffices.

- When we kill a dnsmasq instance, we actually don't have to wait at
all. That can happen fully in background. The only pecularity is that
when we restart a new instance before the previous instance is killed,
then we must wait for the previous process to terminate first. Also, if
we are about to exit while killing the dnsmasq instance, we must register
nm_shutdown_wait_obj_*() to wait until the process is fully gone.
2019-09-26 08:18:58 +02:00
..
c-list shared/c-list: reimport 2019-04-14 17:22:04 +02:00
c-rbtree shared/c-rbtree: reimport 2019-04-14 17:23:01 +02:00
c-siphash shared/c-siphash: reimport 2019-04-14 17:23:25 +02:00
c-stdaux shared: patch c-stdaux.h to not include <stdatomic.h> 2019-04-14 17:17:52 +02:00
n-acd n-acd: fix leaking socket handle in n_acd_socket_new() when setsockopt() fails 2019-08-02 11:26:25 +02:00
n-dhcp4 n-dhcp4: arm timers in bound state 2019-09-18 09:29:51 +02:00
nm-glib-aux dns/dnsmasq: refactor tracking of dnsmasq process 2019-09-26 08:18:58 +02:00
nm-libnm-core-aux all: SPDX header conversion 2019-09-10 11:19:56 +02:00
nm-libnm-core-intern all: SPDX header conversion 2019-09-10 11:19:56 +02:00
nm-std-aux shared,all: add and use DBUS_INTERFACE_OBJECT_MANAGER define 2019-09-22 16:05:50 +02:00
nm-udev-aux all: SPDX header conversion 2019-09-10 11:19:56 +02:00
nm-utils shared: add compat macro for G_PID_FORMAT 2019-09-26 08:18:58 +02:00
systemd systemd: merge branch systemd into master 2019-09-25 09:14:30 +02:00
meson.build shared: add NMRefString 2019-09-21 14:58:26 +02:00
nm-default.h all: SPDX header conversion 2019-09-10 11:19:56 +02:00
nm-meta-setting.c all: SPDX header conversion 2019-09-10 11:19:56 +02:00
nm-meta-setting.h all: SPDX header conversion 2019-09-10 11:19:56 +02:00
nm-test-libnm-utils.h all: SPDX header conversion 2019-09-10 11:19:56 +02:00
nm-test-utils-impl.c all: SPDX header conversion 2019-09-10 11:19:56 +02:00
nm-version-macros.h.in all: SPDX header conversion 2019-09-10 11:19:56 +02:00