}
}
+void ServiceRecord::notify_dependencies_stopped() noexcept
+{
+ if (desired_state == ServiceState::STOPPED) {
+ // Stop any dependencies whose desired state is STOPPED:
+ for (auto i = depends_on.begin(); i != depends_on.end(); i++) {
+ (*i)->dependentStopped();
+ }
+ for (auto i = soft_deps.begin(); i != soft_deps.end(); i++) {
+ i->getTo()->dependentStopped();
+ }
+
+ service_set->service_inactive(this);
+ }
+}
+
// Called when a service has actually stopped.
void ServiceRecord::stopped() noexcept
{
socket_fd = -1;
}
- service_set->service_inactive(this);
-
- // Stop any dependencies whose desired state is STOPPED:
- for (auto i = depends_on.begin(); i != depends_on.end(); i++) {
- (*i)->dependentStopped();
- }
- for (auto i = soft_deps.begin(); i != soft_deps.end(); i++) {
- i->getTo()->dependentStopped();
- }
+ notify_dependencies_stopped();
}
}
logServiceFailed(service_name);
service_state = ServiceState::STOPPED;
- desired_state = ServiceState::STOPPED;
- service_set->service_inactive(this);
notifyListeners(ServiceEvent::FAILEDSTART);
- // Stop any dependencies whose desired state is STOPPED:
- for (auto i = depends_on.begin(); i != depends_on.end(); i++) {
- (*i)->dependentStopped();
- }
- for (auto i = soft_deps.begin(); i != soft_deps.end(); i++) {
- i->getTo()->dependentStopped();
- }
+ notify_dependencies_stopped();
// Cancel start of dependents:
for (sr_iter i = dependents.begin(); i != dependents.end(); i++) {
}
desired_state = ServiceState::STOPPED;
+
+ if (service_state == ServiceState::STOPPED) {
+ notify_dependencies_stopped();
+ return;
+ }
do_stop();
}
return waiting_for_deps && ! force_stop;
}
+ // Notify dependencies that we no longer need them,
+ // (if this is actually the case).
+ void notify_dependencies_stopped() noexcept;
+
// A dependent has reached STOPPED state
void dependentStopped() noexcept;