Browse Source

Force-stop as part of restart(), do not require separate force-stop

Davin McCall 3 years ago
parent
commit
9fd61240f5
3 changed files with 4 additions and 4 deletions
  1. 3 1
      src/control.cc
  2. 1 0
      src/service.cc
  3. 0 3
      src/tests/tests.cc

+ 3 - 1
src/control.cc

@@ -290,7 +290,9 @@ bool control_conn_t::process_start_stop(int pktType)
                 service->stop(true);
                 wanted_state = service_state_t::STOPPED;
             }
-            service->forced_stop();
+            if (!do_restart) {
+                service->forced_stop();
+            }
             services->process_queues();
             if (service->get_state() == wanted_state && !do_restart) ack_buf[0] = DINIT_RP_ALREADYSS;
             break;

+ 1 - 0
src/service.cc

@@ -548,6 +548,7 @@ bool service_record::restart() noexcept
     if (service_state == service_state_t::STARTED) {
         restarting = true;
         stop_reason = stopped_reason_t::NORMAL;
+        force_stop = true;
         do_stop();
         return true;
     }

+ 0 - 3
src/tests/tests.cc

@@ -1139,7 +1139,6 @@ void test_other3()
     s1->add_listener(&tl);
 
     s1->restart();
-    s1->forced_stop();
     sset.process_queues();
 
     assert(s3->get_state() == service_state_t::STARTED);
@@ -1178,7 +1177,6 @@ void test_other4()
     assert(s1->get_state() == service_state_t::STARTED);
 
     s1->restart();
-    s1->forced_stop();
     sset.process_queues();
 
     assert(s2->get_state() == service_state_t::STARTED);
@@ -1226,7 +1224,6 @@ void test_other5()
     s1->auto_stop = false;
 
     s1->restart();
-    s1->forced_stop();
     sset.process_queues();
 
     assert(s1->get_state() == service_state_t::STOPPING);