core: add ReloadCount to Manager and bump on successful reload

Introduce a counter that tracks how many configuration reloads have
been successfully completed by the manager. The increment lives in
manager_reload() right after the "point of no return", so failed
reload attempts that bail out earlier (e.g. during serialization)
do not bump the counter.

It is accessible as a new ReloadCount property to
org.freedesktop.systemd1.Manager (D-Bus) and ReloadCount to
io.systemd.Manager.Describe (Varlink).

Also add an integration test for ReloadCount
that verifies that the new ReloadCount property increments by one per
daemon-reload, accumulates correctly across multiple reloads, and that
D-Bus and Varlink return identical values. Also tests that the counter
reset after a reexec.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Simon Lucido <simonlucido@meta.com>
This commit is contained in:
Simon Lucido
2026-05-03 10:23:55 +01:00
committed by Luca Boccassi
parent db28490c9f
commit d667b6b97f
8 changed files with 81 additions and 4 deletions
+4
View File
@@ -3650,6 +3650,10 @@ int manager_reload(Manager *m) {
/* 💀 This is the point of no return, from here on there is no way back. 💀 */
reloading = NULL;
/* Bump before sending the Reloading signal, so any client that reads
* ReloadCount in response to that signal observes the new value. */
m->reload_count = saturate_add(m->reload_count, 1, UINT64_MAX);
bus_manager_send_reloading(m, true);
/* Start by flushing out all jobs and units, all generated units, all runtime environments, all dynamic users