restarting |= auto_restart;
bool will_restart = restarting && required_by > 0;
+ if (restarting && ! will_restart) {
+ notify_listeners(service_event_t::STARTCANCELLED);
+ }
restarting = false;
// If we won't restart, break soft dependencies now
{
if (--required_by == 0) {
desired_state = service_state_t::STOPPED;
+ prop_require = false;
// Can stop, and can release dependencies now. We don't need to issue a release if
// the require was pending though:
bring_down = true;
}
+ desired_state = service_state_t::STOPPED;
+
if (bring_down && service_state != service_state_t::STOPPED
&& service_state != service_state_t::STOPPING) {
stop_reason = stopped_reason_t::NORMAL;
}
}
-void service_record::restart() noexcept
+bool service_record::restart() noexcept
{
// Re-start without affecting dependency links/activation.
restarting = true;
stop_reason = stopped_reason_t::NORMAL;
do_stop();
+ return true;
}
+
+ // Wrong state
+ return false;
}
void service_record::do_stop() noexcept
if (pinned_started) return;
- if (required_by == 0) {
- prop_release = true;
- services->add_prop_queue(this);
- }
-
service_state = service_state_t::STOPPING;
waiting_for_deps = true;
if (all_deps_stopped) {
dept->get_from()->prop_stop = true;
services->add_prop_queue(dept->get_from());
}
+ // Note that soft dependencies are held (for now). If we restart, we don't want those dependencies
+ // to be broken.
}
return all_deps_stopped;