From 111308b3e5766b24537483655659c1b4984b2e10 Mon Sep 17 00:00:00 2001
From: obarun <eric@obarun.org>
Date: Fri, 17 May 2024 19:30:37 +1100
Subject: [PATCH] always take care of service inside module whatever their own
 state

---
 src/lib66/service/service_graph_collect.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/lib66/service/service_graph_collect.c b/src/lib66/service/service_graph_collect.c
index 3dc8b07e..6830a577 100644
--- a/src/lib66/service/service_graph_collect.c
+++ b/src/lib66/service/service_graph_collect.c
@@ -145,6 +145,27 @@ void service_graph_collect(graph_t *g, char const *slist, size_t slen, struct re
 
             }
 
+            /**
+             * In case of crash of a command and for whatever the reason, the
+             * service inside the module may not corresponds to the state of the
+             * module itself.
+             *
+             * Whatever the current state of service inside the module, we keep
+             * trace of its because others commands will look for these inner services.
+             *
+             * At the end of any process, the ssexec_signal will deal properly
+             * with the current state and the desire state of the service. */
+            if (res.type == TYPE_MODULE && res.dependencies.ncontents) {
+
+                size_t len = strlen(res.sa.s + res.dependencies.contents) ;
+                _init_stack_(stk, len + 1) ;
+
+                if (!stack_clean_string(&stk, res.sa.s + res.dependencies.contents, len))
+                    log_dieusys(LOG_EXIT_SYS, "clean string") ;
+
+                service_graph_collect(g, stk.s, stk.len, hres, info, flag) ;
+            }
+
             free(wres) ;
         }
     }
-- 
GitLab