saned: fix child lifecycle management in standalone mode

This patch series:

  • fixes #776 (closed), one user-visible bug preventing clean shutdown in standalone mode when not daemonised,
  • fixes two internal defects noticed in development and
  • enhances the standalone mode (including when daemonised) to avoid waking up the processor every 500ms, by using pidfds (Linux >= 5.3)

The enhancement involves reworking how child processes and fds are managed, generalising how client connection and avahi processes are handled and allowing pidfds to be multiplexed with listener fds in the poll loop.

While conceptually independent from the fixes, the pidfds work does build on them hence why initially in the same patch series.

I've tried to honour the coding style of the existing code - I hope I've been moderately successful in that!

Fixed shutdown

2024-10-13_23:38:25.92038 [saned] do_bindings: [0] socket () using IPv4
2024-10-13_23:38:25.92039 [saned] do_bindings: [0] setsockopt ()
2024-10-13_23:38:25.92039 [saned] do_bindings: [0] bind () to port 6566
2024-10-13_23:38:25.92039 [saned] do_bindings: [0] bind failed: Address already in use
2024-10-13_23:38:25.92041 [saned] Dropped privileges to uid 105 gid 115
2024-10-13_23:38:25.92041 [saned] run_standalone: spawning Avahi process
2024-10-13_23:38:25.92048 [saned] run_standalone: waiting for control connection
2024-10-13_23:38:25.92098 [saned] saned_avahi_callback: AVAHI_CLIENT_S_RUNNING
2024-10-13_23:38:25.92106 [saned] saned_create_avahi_services: adding service 'saned'
2024-10-13_23:38:26.73586 [saned] saned_avahi_group_callback: service 'saned' successfully established
2024-10-13_23:39:04.79644 [saned] bailing out, waiting for children...
2024-10-13_23:39:04.79657 [saned] bail_out: all children exited

I hope this series is of interest, thanks!

Merge request reports

Loading