Simplify allDepStarted logic.
authorDavin McCall <davmac@davmac.org>
Tue, 30 May 2017 10:10:23 +0000 (11:10 +0100)
committerDavin McCall <davmac@davmac.org>
Tue, 30 May 2017 10:10:23 +0000 (11:10 +0100)
Change default action of start_ps_process to call started(). This is
overriden in base_process_service to launch the process.

src/service.cc
src/service.h

index 375d66b9919cdf5bdfbfdeb3b1ea6c54c83e6068..e9a9577fb35fee72dc81d6d7792207bf71df5e7c 100644 (file)
@@ -636,16 +636,9 @@ void ServiceRecord::allDepsStarted(bool has_console) noexcept
         failed_to_start();
     }
 
-    if (service_type == ServiceType::PROCESS || service_type == ServiceType::BGPROCESS
-            || service_type == ServiceType::SCRIPTED) {
-        bool start_success = start_ps_process();
-        if (! start_success) {
-            failed_to_start();
-        }
-    }
-    else {
-        // "internal" service
-        started();
+    bool start_success = start_ps_process();
+    if (! start_success) {
+        failed_to_start();
     }
 }
 
@@ -762,6 +755,8 @@ void ServiceRecord::failed_to_start(bool depfailed) noexcept
 
 bool ServiceRecord::start_ps_process() noexcept
 {
+    // default implementation: there is no process, so we are started.
+    started();
     return true;
 }
 
index 9468e4d1d9d305c082ef356746b0c814d71b5771..70b55afd995ee5561d277f154ddd48d3f77a1d1b 100644 (file)
@@ -583,6 +583,8 @@ class base_process_service : public ServiceRecord
 
 class process_service : public base_process_service
 {
+    // called when the process exits. The exit_status is the status value yielded by
+    // the "wait" system call.
     virtual void handle_exit_status(int exit_status) noexcept override;
 
     public: