Fix restart after unexpected termination.
[oweals/dinit.git] / src / service.cc
index aa00cee8f18925435ea6fc07acbbbc9be7fcd086..504a9b6de0836710449785effbac4a3f04b97452 100644 (file)
@@ -54,7 +54,6 @@ void service_record::stopped() noexcept
 {
     if (have_console) {
         bp_sys::tcsetpgrp(0, bp_sys::getpgrp());
-        discard_console_log_buffer();
         release_console();
     }
 
@@ -72,7 +71,7 @@ void service_record::stopped() noexcept
     }
 
     bool will_restart = (desired_state == service_state_t::STARTED)
-            && services->get_auto_restart();
+            && !services->is_shutting_down();
 
     for (auto & dependency : depends_on) {
         // we signal dependencies in case they are waiting for us to stop:
@@ -131,7 +130,7 @@ void service_record::stopped() noexcept
 bool service_record::do_auto_restart() noexcept
 {
     if (auto_restart) {
-        return services->get_auto_restart();
+        return !services->is_shutting_down();
     }
     return false;
 }
@@ -459,7 +458,7 @@ void service_record::forced_stop() noexcept
         force_stop = true;
         if (! pinned_started) {
             prop_stop = true;
-            services->add_transition_queue(this);
+            services->add_prop_queue(this);
         }
     }
 }