From 575842a22e03df1bd752548f63673b20e15febd7 Mon Sep 17 00:00:00 2001
From: obarun <eric@obarun.org>
Date: Wed, 31 May 2023 16:55:22 +1100
Subject: [PATCH] do not deal with unsupervised service on stop process

---
 src/lib66/sanitize/sanitize_source.c    |  3 ++-
 src/lib66/service/service_graph_build.c | 12 ++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/lib66/sanitize/sanitize_source.c b/src/lib66/sanitize/sanitize_source.c
index c30a3279..ead5f1c0 100644
--- a/src/lib66/sanitize/sanitize_source.c
+++ b/src/lib66/sanitize/sanitize_source.c
@@ -29,7 +29,8 @@ void sanitize_source(char const *name, ssexec_t *info)
 {
     log_flow() ;
 
-    int r, logname = get_rstrlen_until(name,SS_LOG_SUFFIX) ;
+    int r ;
+    ssize_t logname = get_rstrlen_until(name,SS_LOG_SUFFIX) ;
     char atree[SS_MAX_TREENAME + 1] ;
 
     r = service_is_g(atree, name, STATE_FLAGS_ISPARSED) ;
diff --git a/src/lib66/service/service_graph_build.c b/src/lib66/service/service_graph_build.c
index c593c6e2..0b823dda 100644
--- a/src/lib66/service/service_graph_build.c
+++ b/src/lib66/service/service_graph_build.c
@@ -67,6 +67,7 @@ void service_graph_build(graph_t *g, resolve_service_t *ares, unsigned int aresl
     log_flow() ;
 
     unsigned int pos = 0 ;
+    ss_state_t ste = STATE_ZERO ;
     resolve_service_t_ref pres = 0 ;
 
     for (; pos < areslen ; pos++) {
@@ -74,6 +75,17 @@ void service_graph_build(graph_t *g, resolve_service_t *ares, unsigned int aresl
         pres = &ares[pos] ;
         char *service = pres->sa.s + pres->name ;
 
+        if (!state_check(&ares[pos]))
+            continue ;
+
+        if (!state_read(&ste, &ares[pos]))
+            continue ;
+
+        if (service_is(&ste, STATE_FLAGS_ISSUPERVISED) == STATE_FLAGS_FALSE && FLAGS_ISSET(flag, STATE_FLAGS_ISSUPERVISED)) {
+            log_warn("service: ", service, " not available -- ignore it") ;
+            continue ;
+        }
+
         if (!graph_vertex_add(g, service))
             log_dieu(LOG_EXIT_SYS, "add vertex: ", service) ;
 
-- 
GitLab