Clear condition before stopping rdeps on reload#484
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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