From 9e8672e37b5d5f67bd7d3b99a72282e167177a5b Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Mon, 8 Jan 2018 19:42:34 +0000 Subject: [PATCH] Rename service_type (type) to service_type_t. 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 | 18 +++++++------- src/service-constants.h | 2 +- src/service.cc | 8 +++---- src/service.h | 18 +++++++------- src/tests/test_service.h | 2 +- src/tests/tests.cc | 52 ++++++++++++++++++++-------------------- 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/load_service.cc b/src/load_service.cc index dd77937..7a3578f 100644 --- a/src/load_service.cc +++ b/src/load_service.cc @@ -388,7 +388,7 @@ service_record * dirload_service_set::load_service(const char * name) list> stop_command_offsets; string pid_file; - service_type service_type = service_type::PROCESS; + service_type_t service_type = service_type_t::PROCESS; std::list 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); diff --git a/src/service-constants.h b/src/service-constants.h index ad3cc2b..9a5e477 100644 --- a/src/service-constants.h +++ b/src/service-constants.h @@ -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) diff --git a/src/service.cc b/src/service.cc index bed9f2e..4315682 100644 --- a/src/service.cc +++ b/src/service.cc @@ -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> &command_offsets, const std::list &deplist_p) : service_record(sset, name, service_type_p, deplist_p), child_listener(this), diff --git a/src/service.h b/src/service.h index c2934f4..0e05da4 100644 --- a/src/service.h +++ b/src/service.h @@ -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 &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> &command_offsets, const std::list &deplist_p); @@ -752,7 +752,7 @@ class process_service : public base_process_service process_service(service_set *sset, string name, string &&command, std::list> &command_offsets, std::list 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> &command_offsets, std::list 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> &command_offsets, std::list 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) { } diff --git a/src/tests/test_service.h b/src/tests/test_service.h index eeb7605..50daeae 100644 --- a/src/tests/test_service.h +++ b/src/tests/test_service.h @@ -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 &deplist_p) : service_record(set, name, type_p, deplist_p) { diff --git a/src/tests/tests.cc b/src/tests/tests.cc index 0ee0ebf..c7b9f08 100644 --- a/src/tests/tests.cc +++ b/src/tests/tests.cc @@ -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); -- 2.25.1