Re: dnsmasq dependency on dbus? Reply #15 – 11 December 2019, 17:12:44 Quote from: dnkl – on 11 December 2019, 16:44:18From a human perspective it does. But it has to execute X number of instructions to get there. This creates a small window where the process is running but the service hasn't fully started up. More or less all services have this problem.So, it's a race; sometimes dnsmasq is started and tries to connect to dbus before it is accepting connections. Other times dbus wins the race.PID-file based service managers are actually better off since they effectively let the services decide when they've started. Dbus, for example, can hold off with writing its PID-file until after it has started accepting connections.Hmm, I thought s6's dependency management is supposed to magically solve this problem in a race-free way. Admittedly, I don't know how it really works Quote Selected
Re: dnsmasq dependency on dbus? Reply #16 – 11 December 2019, 19:03:05 It might be possible to do something with s6's variant of socket activation, but I'm not familiar enough with s6 to say how, it if it even can be done. Quote Selected
Re: dnsmasq dependency on dbus? Reply #17 – 12 December 2019, 17:42:11 When I get some free time I'll play around with this: https://skarnet.org/software/s6/notifywhenup.html Quote Selected
Re: dnsmasq dependency on dbus? Reply #18 – 12 December 2019, 19:26:42 Quotes6 supports that mechanism natively: when the service directory for the daemon contains a valid notification-fd file, the daemon's supervisor, i.e. the s6-supervise program, will properly catch the daemon's message, update the status file (supervise/status), then notify all the subscribers with a 'U' event, meaning that the service is now up and ready.Interesting. So it sounds like a patch doing that for dbus would completely solve the problem. Not sure how easy/difficult that would be of course. Quote Selected
Re: dnsmasq dependency on dbus? Reply #19 – 13 December 2019, 15:28:54 Preliminary result: this looks like it was a lot easier than I had anticipated.I'm piggybacking on dbus' --print-pid=fd option. I figured that it writes the PID to this fd at the same time it creates the PID file, which should be after it is done initializing.For a "real" pipe (not stdout or stderr) it closes the fd right after writing to it (verified by strace:ing). Thereby fulfilling s6's requirements for a notification-fd.So, here's what I did:* Revert the dbus policy (i.e. only allow root)* Added /etc/s6/sv/dbus/notification-fd, with the content '3'* Added --print-pid=3 to /etc/s6/sv/dbus/run* Added dbus as a dependency to dnsmasq5-6 reboots later I haven't seen a single dbus connection failure. Quote Selected 1 Likes
Re: dnsmasq dependency on dbus? Reply #20 – 13 December 2019, 15:52:35 Quote* Revert the dbus policy (i.e. only allow root)Note that I still thinks it is a good idea to have the dnsmasq user allowed in the policy since we are running as that user. I reverted it just to verify the notification-fd worked. Quote Selected
Re: dnsmasq dependency on dbus? Reply #21 – 13 December 2019, 16:20:02 Quote from: dnkl – on 13 December 2019, 15:28:54Preliminary result: this looks like it was a lot easier than I had anticipated.I'm piggybacking on dbus' --print-pid=fd option. I figured that it writes the PID to this fd at the same time it creates the PID file, which should be after it is done initializing.For a "real" pipe (not stdout or stderr) it closes the fd right after writing to it (verified by strace:ing). Thereby fulfilling s6's requirements for a notification-fd.So, here's what I did:* Revert the dbus policy (i.e. only allow root)* Added /etc/s6/sv/dbus/notification-fd, with the content '3'* Added --print-pid=3 to /etc/s6/sv/dbus/run* Added dbus as a dependency to dnsmasq5-6 reboots later I haven't seen a single dbus connection failure.This is great! I didn't know dbus had such a handy option. Not only would dnsmasq benefit from this, but so does every other service that depends on dbus (which is quite a few of course). Doing this would make dnsmasq-s6 have a hard dependency on dbus-s6, but I think at this point, it's probably OK. Quote Selected