Properly issue STARTCANCELLED message if restart is cancelled
[oweals/dinit.git] / src / tests / test_service.h
index 7ee377b69543d0806d1584992996e703fc380228..ae47b2ad423392df681a6844881dc9f2438e671e 100644 (file)
@@ -15,6 +15,8 @@ class test_service : public service_record
 
     }
 
+    bool auto_stop = true;  // whether to call stopped() immediately from bring_down()
+
     // Do any post-dependency startup; return false on failure
     virtual bool bring_up() noexcept override
     {
@@ -25,7 +27,15 @@ class test_service : public service_record
     // All dependents have stopped.
     virtual void bring_down() noexcept override
     {
-        return service_record::bring_down();
+        waiting_for_deps = false;
+        if (auto_stop) {
+            stopped();
+        }
+    }
+
+    void stopped() noexcept
+    {
+        service_record::stopped();
     }
 
     // Whether a STARTING service can immediately transition to STOPPED (as opposed to