From: Davin McCall Date: Thu, 7 Jan 2016 20:45:09 +0000 (+0000) Subject: Refactoring: remove unneeded method X-Git-Tag: v0.01~49 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=46a87ca979849664eaddf72589e3d3eff895f841;p=oweals%2Fdinit.git Refactoring: remove unneeded method --- diff --git a/src/service.cc b/src/service.cc index 4fec13b..c4667bb 100644 --- a/src/service.cc +++ b/src/service.cc @@ -506,9 +506,9 @@ void ServiceRecord::started() noexcept } } -void ServiceRecord::failed_to_start() +void ServiceRecord::failed_to_start(bool depfailed) noexcept { - if (onstart_flags.runs_on_console) { + if (!depfailed && onstart_flags.runs_on_console) { tcsetpgrp(0, getpgrp()); releaseConsole(); } @@ -519,11 +519,10 @@ void ServiceRecord::failed_to_start() service_set->service_inactive(this); notifyListeners(ServiceEvent::FAILEDSTART); - // failure to start // Cancel start of dependents: for (sr_iter i = dependents.begin(); i != dependents.end(); i++) { if ((*i)->service_state == ServiceState::STARTING) { - (*i)->failed_dependency(); + (*i)->failed_to_start(true); } } for (auto i = soft_dpts.begin(); i != soft_dpts.end(); i++) { @@ -666,30 +665,6 @@ void ServiceRecord::forceStop() noexcept } } -// A dependency of this service failed to start. -// Only called when state == STARTING. -void ServiceRecord::failed_dependency() -{ - desired_state = ServiceState::STOPPED; - - // Presumably, we were starting. So now we're not. - service_state = ServiceState::STOPPED; - service_set->service_inactive(this); - logServiceFailed(service_name); - - // Notify dependents of this service also - for (auto i = dependents.begin(); i != dependents.end(); i++) { - if ((*i)->service_state == ServiceState::STARTING) { - (*i)->failed_dependency(); - } - } - for (auto i = soft_dpts.begin(); i != soft_dpts.end(); i++) { - // It's a soft dependency, so send them 'started' rather than - // 'failed dep'. - (*i)->getFrom()->dependencyStarted(); - } -} - void ServiceRecord::dependentStopped() noexcept { if (service_state == ServiceState::STOPPING) { diff --git a/src/service.h b/src/service.h index cbeab72..3d7bc45 100644 --- a/src/service.h +++ b/src/service.h @@ -235,12 +235,10 @@ class ServiceRecord // Service has successfully started void started() noexcept; - // Service failed to start - void failed_to_start(); - - // A dependency of this service failed to start. - void failed_dependency(); - + // Service failed to start (only called when in STARTING state). + // dep_failed: whether failure is recorded due to a dependency failing + void failed_to_start(bool dep_failed = false) noexcept; + // For process services, start the process, return true on success bool start_ps_process() noexcept; bool start_ps_process(const std::vector &args, bool on_console) noexcept;