Skip to content

Clear condition before stopping rdeps on reload#484

Merged
troglobit merged 1 commit intomasterfrom
rdep-stop-cond
Mar 19, 2026
Merged

Clear condition before stopping rdeps on reload#484
troglobit merged 1 commit intomasterfrom
rdep-stop-cond

Conversation

@troglobit
Copy link
Collaborator

When a service without SIGHUP reload support (noreload) is touched and 'initctl reload' is called, service_update_rdeps() correctly identifies its reverse dependencies but only marks them dirty. It does not clear the service's condition, so when service_step_all() runs:

  • rdeps supporting SIGHUP hit the sm_in_reload() guard and break early, left running while their dependency is being killed.
  • rdeps without SIGHUP support may receive SIGTERM too late, after the dependency has already died and broken their connection, causing them to exit from RUNNING state and have their restart counter incremented.

Fix by calling cond_clear() on the service's condition immediately in service_update_rdeps(), before service_step_all() runs. cond_clear() calls cond_update() which calls service_step() inline on all affected services, which see COND_OFF and transition to STOPPING_STATE — all before SIGTERM is ever sent to the dependency itself.

This mirrors the pattern already used in api.c:do_reload() for direct 'initctl reload ' calls.

Fixes: avahi-daemon stop causing dependant mdns-alias restart counter increment

When a service without SIGHUP reload support (noreload) is touched and
'initctl reload' is called, service_update_rdeps() correctly identifies
its reverse dependencies but only marks them dirty.  It does not clear
the service's condition, so when service_step_all() runs:

 - rdeps supporting SIGHUP hit the sm_in_reload() guard and break early,
   left running while their dependency is being killed.
 - rdeps without SIGHUP support may receive SIGTERM too late, after the
   dependency has already died and broken their connection, causing them
   to exit from RUNNING state and have their restart counter incremented.

Fix by calling cond_clear() on the service's condition immediately in
service_update_rdeps(), before service_step_all() runs.  cond_clear()
calls cond_update() which calls service_step() inline on all affected
services, which see COND_OFF and transition to STOPPING_STATE — all
before SIGTERM is ever sent to the dependency itself.

This mirrors the pattern already used in api.c:do_reload() for direct
'initctl reload <svc>' calls.

Fixes: avahi/mdns stop causing mdns-alias restart counter increment

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
@troglobit troglobit merged commit 50b9e46 into master Mar 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant