NetworkManager/src/dhcp-manager
Thomas Haller e678bd29a4 dhcp: call synchronous Notify D-Bus method from nm-dhcp-helper
A D-Bus signal is asynchronous and it can happen that nm-dhcp-helper
emits the "Event" signal before the server is able to register a handler:

   NM_DHCP_HELPER=/usr/libexec/nm-dhcp-helper
   nmcli general logging level TRACE
   for i in `seq 1 500`; do $NM_DHCP_HELPER & done
   journalctl -u NetworkManager --since '1 min ago' | grep "didn't have associated interface" | wc -l
    499

Avoid that, by calling the synchronous D-Bus method "Notify".

Interestingly, this race seem to exist since 2007.

Actually, we called g_dbus_connection_signal_subscribe() from inside
GDBusServer:new-connection signal. So it is not clear how such a race
could exist. I was not able to reproduce it by putting a sleep
before g_dbus_connection_signal_subscribe(). On the other hand, there
is bug rh#1372854 and above reproducer which strongly indicates that
events can be lost under certain circumstances.
Now we instead g_dbus_connection_register_object() from the
new-connection signal. According to my tests there was no more race
as also backed by glib's documentation. Still, keep a simple retry-loop
in nm-dhcp-helper just to be sure.

https://bugzilla.redhat.com/show_bug.cgi?id=1372854
https://bugzilla.redhat.com/show_bug.cgi?id=1373276
(cherry picked from commit 2856a658b3)
2016-09-08 00:26:14 +02:00
..
tests dhcp: let users override FQDN dhclient options 2016-05-31 14:33:23 +02:00
Makefile.am dhcp: add new header "nm-dhcp-helper-api.h" 2016-09-08 00:26:14 +02:00
nm-dhcp-client-logging.h all: cleanup includes in header files 2016-08-17 19:51:17 +02:00
nm-dhcp-client.c dhcp: drop an unused fariable 2016-07-13 12:26:15 +02:00
nm-dhcp-client.h all: cleanup includes in header files 2016-08-17 19:51:17 +02:00
nm-dhcp-dhclient-utils.c dhcp: let users override FQDN dhclient options 2016-05-31 14:33:23 +02:00
nm-dhcp-dhclient-utils.h build: cleanup src/Makefile.am 2016-08-11 11:54:18 +02:00
nm-dhcp-dhclient.c dhcp: let dhcp clients hold a reference to NMDhcpListener 2016-07-01 14:57:18 +02:00
nm-dhcp-dhclient.h all: cleanup includes in header files 2016-08-17 19:51:17 +02:00
nm-dhcp-dhcpcd.c dhcp: let dhcp clients hold a reference to NMDhcpListener 2016-07-01 14:57:18 +02:00
nm-dhcp-dhcpcd.h all: rename nm-glib-compat.h to nm-glib.h, use everywhere 2015-07-24 13:25:47 -04:00
nm-dhcp-helper-api.h dhcp: call synchronous Notify D-Bus method from nm-dhcp-helper 2016-09-08 00:26:14 +02:00
nm-dhcp-helper.c dhcp: call synchronous Notify D-Bus method from nm-dhcp-helper 2016-09-08 00:26:14 +02:00
nm-dhcp-listener.c dhcp: call synchronous Notify D-Bus method from nm-dhcp-helper 2016-09-08 00:26:14 +02:00
nm-dhcp-listener.h dhcp-listener: refactor type definition and embed private data in @self 2016-09-08 00:26:14 +02:00
nm-dhcp-manager.c dhcp: prefix logging messages with "dhcp" 2016-07-10 13:22:12 +02:00
nm-dhcp-manager.h all: cleanup includes in header files 2016-08-17 19:51:17 +02:00
nm-dhcp-systemd.c dhcp/systemd: honor timeout for DHCPv6 2016-08-24 18:01:18 +02:00
nm-dhcp-systemd.h all: rename nm-glib-compat.h to nm-glib.h, use everywhere 2015-07-24 13:25:47 -04:00
nm-dhcp-utils.c all: reuse _nm_utils_hwaddr_ntoa() for converting binary to string 2016-07-10 13:44:58 +02:00
nm-dhcp-utils.h all: cleanup includes in header files 2016-08-17 19:51:17 +02:00