Rename service_type (type) to service_type_t.
authorDavin McCall <davmac@davmac.org>
Mon, 8 Jan 2018 19:42:34 +0000 (19:42 +0000)
committerDavin McCall <davmac@davmac.org>
Mon, 8 Jan 2018 19:42:34 +0000 (19:42 +0000)
This is consistent with a number of other service-related types, and as
a bonus makes building with GCC 4.8 possible (it was previously confused
by a "service_type service_type = ..." declaration).

src/load_service.cc
src/service-constants.h
src/service.cc
src/service.h
src/tests/test_service.h
src/tests/tests.cc

index dd77937ecf9cd0c714faf8812907b1d5e6b4850d..7a3578ffb78da955282f0fcc7bb5632645a9ae83 100644 (file)
@@ -388,7 +388,7 @@ service_record * dirload_service_set::load_service(const char * name)
     list<pair<unsigned,unsigned>> stop_command_offsets;
     string pid_file;
 
-    service_type service_type = service_type::PROCESS;
+    service_type_t service_type = service_type_t::PROCESS;
     std::list<prelim_dep> depends;
     string logfile;
     onstart_flags_t onstart_flags;
@@ -505,16 +505,16 @@ service_record * dirload_service_set::load_service(const char * name)
                 else if (setting == "type") {
                     string type_str = read_setting_value(i, end);
                     if (type_str == "scripted") {
-                        service_type = service_type::SCRIPTED;
+                        service_type = service_type_t::SCRIPTED;
                     }
                     else if (type_str == "process") {
-                        service_type = service_type::PROCESS;
+                        service_type = service_type_t::PROCESS;
                     }
                     else if (type_str == "bgprocess") {
-                        service_type = service_type::BGPROCESS;
+                        service_type = service_type_t::BGPROCESS;
                     }
                     else if (type_str == "internal") {
-                        service_type = service_type::INTERNAL;
+                        service_type = service_type_t::INTERNAL;
                     }
                     else {
                         throw service_description_exc(name, "Service type must be one of: \"scripted\","
@@ -592,7 +592,7 @@ service_record * dirload_service_set::load_service(const char * name)
         
         service_file.close();
         
-        if (service_type == service_type::PROCESS || service_type == service_type::BGPROCESS || service_type == service_type::SCRIPTED) {
+        if (service_type == service_type_t::PROCESS || service_type == service_type_t::BGPROCESS || service_type == service_type_t::SCRIPTED) {
             if (command.length() == 0) {
                 throw service_description_exc(name, "Service command not specified");
             }
@@ -603,7 +603,7 @@ service_record * dirload_service_set::load_service(const char * name)
             if (*iter == rval) {
                 // We've found the dummy record
                 delete rval;
-                if (service_type == service_type::PROCESS) {
+                if (service_type == service_type_t::PROCESS) {
                     auto rvalps = new process_service(this, string(name), std::move(command),
                             command_offsets, depends);
                     rvalps->set_restart_interval(restart_interval, max_restarts);
@@ -613,7 +613,7 @@ service_record * dirload_service_set::load_service(const char * name)
                     rvalps->set_start_interruptible(start_is_interruptible);
                     rval = rvalps;
                 }
-                else if (service_type == service_type::BGPROCESS) {
+                else if (service_type == service_type_t::BGPROCESS) {
                     auto rvalps = new bgproc_service(this, string(name), std::move(command),
                             command_offsets, depends);
                     rvalps->set_pid_file(std::move(pid_file));
@@ -624,7 +624,7 @@ service_record * dirload_service_set::load_service(const char * name)
                     rvalps->set_start_interruptible(start_is_interruptible);
                     rval = rvalps;
                 }
-                else if (service_type == service_type::SCRIPTED) {
+                else if (service_type == service_type_t::SCRIPTED) {
                     auto rvalps = new scripted_service(this, string(name), std::move(command),
                             command_offsets, depends);
                     rvalps->set_stop_command(stop_command, stop_command_offsets);
index ad3cc2b48d207d4b382ddfdc776ae773c97f705a..9a5e4772889bfec0fad95f591fe6cbb151f84978 100644 (file)
@@ -10,7 +10,7 @@ enum class service_state_t {
 };
 
 /* Service types */
-enum class service_type {
+enum class service_type_t {
     DUMMY,      // Dummy service, used to detect cyclice dependencies
     PROCESS,    // Service runs as a process, and can be stopped by
                 // sending the process a signal (usually SIGTERM)
index bed9f2e0171f36a1db40f6b5a1ee554d34d3b4d2..43156823171f03b0a9dc2c21d6b9b38bcd911f48 100644 (file)
@@ -416,7 +416,7 @@ rearm exec_status_pipe_watcher::fd_event(eventloop_t &loop, int fd, int flags) n
     }
     else {
         // exec() succeeded.
-        if (sr->get_type() == service_type::PROCESS) {
+        if (sr->get_type() == service_type_t::PROCESS) {
             // This could be a smooth recovery (state already STARTED). Even more, the process
             // might be stopped (and killed via a signal) during smooth recovery.  We don't to
             // process startup again in either case, so we check for state STARTING:
@@ -1283,7 +1283,7 @@ void base_process_service::bring_down() noexcept
         // In most cases, the rest is done in handle_exit_status.
         // If we are a BGPROCESS and the process is not our immediate child, however, that
         // won't work - check for this now:
-        if (get_type() == service_type::BGPROCESS && ! tracking_child) {
+        if (get_type() == service_type_t::BGPROCESS && ! tracking_child) {
             stopped();
         }
         else if (stop_timeout != time_val(0,0)) {
@@ -1320,7 +1320,7 @@ void process_service::bring_down() noexcept
         // In most cases, the rest is done in handle_exit_status.
         // If we are a BGPROCESS and the process is not our immediate child, however, that
         // won't work - check for this now:
-        if (get_type() == service_type::BGPROCESS && ! tracking_child) {
+        if (get_type() == service_type_t::BGPROCESS && ! tracking_child) {
             stopped();
         }
         else if (stop_timeout != time_val(0,0)) {
@@ -1398,7 +1398,7 @@ void service_set::service_inactive(service_record *sr) noexcept
 }
 
 base_process_service::base_process_service(service_set *sset, string name,
-        service_type service_type_p, string &&command,
+        service_type_t service_type_p, string &&command,
         std::list<std::pair<unsigned,unsigned>> &command_offsets,
         const std::list<prelim_dep> &deplist_p)
      : service_record(sset, name, service_type_p, deplist_p), child_listener(this),
index c2934f4375e0958d6ebcb50af9b8263885fe4385..0e05da42c8e8ff954534bf13e7f50277a79d30fb 100644 (file)
@@ -270,7 +270,7 @@ class service_record
     
     private:
     string service_name;
-    service_type record_type;  /* ServiceType::DUMMY, PROCESS, SCRIPTED, INTERNAL */
+    service_type_t record_type;  /* ServiceType::DUMMY, PROCESS, SCRIPTED, INTERNAL */
     service_state_t service_state = service_state_t::STOPPED; /* service_state_t::STOPPED, STARTING, STARTED, STOPPING */
     service_state_t desired_state = service_state_t::STOPPED; /* service_state_t::STOPPED / STARTED */
 
@@ -473,12 +473,12 @@ class service_record
     {
         services = set;
         service_name = name;
-        record_type = service_type::DUMMY;
+        record_type = service_type_t::DUMMY;
         socket_perms = 0;
         exit_status = 0;
     }
 
-    service_record(service_set *set, string name, service_type record_type_p,
+    service_record(service_set *set, string name, service_type_t record_type_p,
             const std::list<prelim_dep> &deplist_p)
         : service_record(set, name)
     {
@@ -497,7 +497,7 @@ class service_record
     }
     
     // Get the type of this service record
-    service_type get_type() noexcept
+    service_type_t get_type() noexcept
     {
         return record_type;
     }
@@ -585,7 +585,7 @@ class service_record
     
     bool isDummy() noexcept
     {
-        return record_type == service_type::DUMMY;
+        return record_type == service_type_t::DUMMY;
     }
     
     // Add a listener. A listener must only be added once. May throw std::bad_alloc.
@@ -700,7 +700,7 @@ class base_process_service : public service_record
     void kill_pg(int signo) noexcept;
 
     public:
-    base_process_service(service_set *sset, string name, service_type record_type_p, string &&command,
+    base_process_service(service_set *sset, string name, service_type_t record_type_p, string &&command,
             std::list<std::pair<unsigned,unsigned>> &command_offsets,
             const std::list<prelim_dep> &deplist_p);
 
@@ -752,7 +752,7 @@ class process_service : public base_process_service
     process_service(service_set *sset, string name, string &&command,
             std::list<std::pair<unsigned,unsigned>> &command_offsets,
             std::list<prelim_dep> depends_p)
-         : base_process_service(sset, name, service_type::PROCESS, std::move(command), command_offsets,
+         : base_process_service(sset, name, service_type_t::PROCESS, std::move(command), command_offsets,
              depends_p)
     {
     }
@@ -780,7 +780,7 @@ class bgproc_service : public base_process_service
     bgproc_service(service_set *sset, string name, string &&command,
             std::list<std::pair<unsigned,unsigned>> &command_offsets,
             std::list<prelim_dep> depends_p)
-         : base_process_service(sset, name, service_type::BGPROCESS, std::move(command), command_offsets,
+         : base_process_service(sset, name, service_type_t::BGPROCESS, std::move(command), command_offsets,
              depends_p)
     {
     }
@@ -800,7 +800,7 @@ class scripted_service : public base_process_service
     scripted_service(service_set *sset, string name, string &&command,
             std::list<std::pair<unsigned,unsigned>> &command_offsets,
             std::list<prelim_dep> depends_p)
-         : base_process_service(sset, name, service_type::SCRIPTED, std::move(command), command_offsets,
+         : base_process_service(sset, name, service_type_t::SCRIPTED, std::move(command), command_offsets,
              depends_p)
     {
     }
index eeb7605365c750f1dbe0227053cacfed5d5f5372..50daeae25a8332db0be07a0b0c422f190fb6f714 100644 (file)
@@ -3,7 +3,7 @@
 class test_service : public service_record
 {
     public:
-    test_service(service_set *set, std::string name, service_type type_p,
+    test_service(service_set *set, std::string name, service_type_t type_p,
             const std::list<prelim_dep> &deplist_p)
             : service_record(set, name, type_p, deplist_p)
     {
index 0ee0ebf3a6a6d1b4e813aefbc60847a6cfec97d4..c7b9f082f4fe619d6eda1aff8ed3bd31c0831763 100644 (file)
@@ -14,9 +14,9 @@ void test1()
 {
     service_set sset;
 
-    service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
-    service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
-    service_record *s3 = new service_record(&sset, "test-service-3", service_type::INTERNAL, {{s2, REG}});
+    service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+    service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+    service_record *s3 = new service_record(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, REG}});
     sset.add_service(s1);
     sset.add_service(s2);
     sset.add_service(s3);
@@ -46,10 +46,10 @@ void test2()
 {
     service_set sset;
 
-    service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
-    service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
-    service_record *s3 = new service_record(&sset, "test-service-3", service_type::INTERNAL, {{s2, REG}});
-    service_record *s4 = new service_record(&sset, "test-service-4", service_type::INTERNAL, {{s2, REG}});
+    service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+    service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+    service_record *s3 = new service_record(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, REG}});
+    service_record *s4 = new service_record(&sset, "test-service-4", service_type_t::INTERNAL, {{s2, REG}});
     sset.add_service(s1);
     sset.add_service(s2);
     sset.add_service(s3);
@@ -87,9 +87,9 @@ void test3()
 {
     service_set sset;
 
-    service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
-    service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
-    service_record *s3 = new service_record(&sset, "test-service-3", service_type::INTERNAL, {{s2, REG}});
+    service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+    service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+    service_record *s3 = new service_record(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, REG}});
     sset.add_service(s1);
     sset.add_service(s2);
     sset.add_service(s3);
@@ -115,9 +115,9 @@ void test4()
 {
     service_set sset;
 
-    service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
-    service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
-    service_record *s3 = new service_record(&sset, "test-service-3", service_type::INTERNAL, {{s2, REG}});
+    service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+    service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+    service_record *s3 = new service_record(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, REG}});
     s2->set_auto_restart(true);
     sset.add_service(s1);
     sset.add_service(s2);
@@ -148,9 +148,9 @@ void test5()
 {
     service_set sset;
 
-    test_service *s1 = new test_service(&sset, "test-service-1", service_type::INTERNAL, {});
-    test_service *s2 = new test_service(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
-    test_service *s3 = new test_service(&sset, "test-service-3", service_type::INTERNAL, {{s2, REG}});
+    test_service *s1 = new test_service(&sset, "test-service-1", service_type_t::INTERNAL, {});
+    test_service *s2 = new test_service(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+    test_service *s3 = new test_service(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, REG}});
 
     sset.add_service(s1);
     sset.add_service(s2);
@@ -187,9 +187,9 @@ void test6()
 {
     service_set sset;
 
-    service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
-    service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
-    service_record *s3 = new service_record(&sset, "test-service-3", service_type::INTERNAL, {{s2, REG}});
+    service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+    service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+    service_record *s3 = new service_record(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, REG}});
     s2->set_auto_restart(true);
     sset.add_service(s1);
     sset.add_service(s2);
@@ -229,9 +229,9 @@ void test7()
 {
     service_set sset;
 
-    service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
-    service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, REG}});
-    service_record *s3 = new service_record(&sset, "test-service-3", service_type::INTERNAL, {{s2, WAITS}});
+    service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+    service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, REG}});
+    service_record *s3 = new service_record(&sset, "test-service-3", service_type_t::INTERNAL, {{s2, WAITS}});
     sset.add_service(s1);
     sset.add_service(s2);
     sset.add_service(s3);
@@ -256,8 +256,8 @@ void test8()
 {
     service_set sset;
 
-    service_record *s1 = new service_record(&sset, "test-service-1", service_type::INTERNAL, {});
-    service_record *s2 = new service_record(&sset, "test-service-2", service_type::INTERNAL, {{s1, MS}});
+    service_record *s1 = new service_record(&sset, "test-service-1", service_type_t::INTERNAL, {});
+    service_record *s2 = new service_record(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, MS}});
     sset.add_service(s1);
     sset.add_service(s2);
 
@@ -282,8 +282,8 @@ void test9()
 {
     service_set sset;
 
-    test_service *s1 = new test_service(&sset, "test-service-1", service_type::INTERNAL, {});
-    test_service *s2 = new test_service(&sset, "test-service-2", service_type::INTERNAL, {{s1, MS}});
+    test_service *s1 = new test_service(&sset, "test-service-1", service_type_t::INTERNAL, {});
+    test_service *s2 = new test_service(&sset, "test-service-2", service_type_t::INTERNAL, {{s1, MS}});
     sset.add_service(s1);
     sset.add_service(s2);