Browse Source

Don't allow commands to operate on placeholder services

Don't show placeholder services in service list; don't allow them to be
started/stopped etc.
Davin McCall 10 months ago
parent
commit
28c2c53f20
2 changed files with 4 additions and 2 deletions
  1. 2 1
      src/control.cc
  2. 2 1
      src/service.cc

+ 2 - 1
src/control.cc

@@ -591,8 +591,9 @@ bool control_conn_t::list_services()
     try {
         auto slist = services->list_services();
         for (auto sptr : slist) {
+        	if (sptr->get_type() == service_type_t::PLACEHOLDER) continue;
+
             std::vector<char> pkt_buf;
-            
             int hdrsize = 2 + STATUS_BUFFER_SIZE;
 
             const std::string &name = sptr->get_name();

+ 2 - 1
src/service.cc

@@ -20,7 +20,7 @@
  * See service.h for details.
  */
 
-// Find the requested service by name
+// Find the requested service by name (will not find placeholder services).
 static service_record * find_service(const std::list<service_record *> & records,
                                     const char *name) noexcept
 {
@@ -28,6 +28,7 @@ static service_record * find_service(const std::list<service_record *> & records
     list<service_record *>::const_iterator i = records.begin();
     for ( ; i != records.end(); ++i ) {
         if (strcmp((*i)->get_name().c_str(), name) == 0) {
+        	if ((*i)->get_type() == service_type_t::PLACEHOLDER) return nullptr;
             return *i;
         }
     }