From 13f803d3b8de3dcaf867d60a19b4e15d578e733b Mon Sep 17 00:00:00 2001
From: obarun <eric@obarun.org>
Date: Sun, 24 Feb 2019 03:29:54 +1100
Subject: [PATCH] fix use of Master

---
 src/lib66/ssexec_all.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/lib66/ssexec_all.c b/src/lib66/ssexec_all.c
index fea15170..d3b318e3 100644
--- a/src/lib66/ssexec_all.c
+++ b/src/lib66/ssexec_all.c
@@ -41,6 +41,7 @@
 #include <66/utils.h>
 #include <66/tree.h>
 #include <66/ssexec.h>
+#include <66/graph.h>
 
 #include <s6/s6-supervise.h>
 #include <s6/config.h>
@@ -57,8 +58,36 @@ int doit(ssexec_t *info, unsigned int what, char const *const *envp)
 	char src[info->tree.len + SS_SVDIRS_LEN + SS_SVC_LEN + 1] ;
 	memcpy(src,info->tree.s,info->tree.len) ;
 	memcpy(src + info->tree.len, SS_SVDIRS,SS_SVDIRS_LEN) ;
-	memcpy(src + info->tree.len +SS_SVDIRS_LEN, SS_SVC,SS_SVC_LEN) ;
-	src[info->tree.len +SS_SVDIRS_LEN + SS_SVC_LEN] = 0 ;
+	src[info->tree.len + SS_SVDIRS_LEN] = 0 ;
+	
+/*	graph_t g = GRAPH_ZERO ;
+	stralloc sagraph = STRALLOC_ZERO ;
+	genalloc tokeep = GENALLOC_ZERO ;
+	int r ;
+	// build dependencies graph
+	r = graph_type_src(&tokeep,src,1) ;
+	if (r <= 0)
+	{
+		strerr_warnwu2x("resolve source of graph for tree: ",src) ;
+		return 0 ;
+	}
+	if (!graph_build(&g,&sagraph,&tokeep,src))
+	{
+		strerr_warnwu1x("make dependencies graph") ;
+		return 0 ;
+	}
+	
+	r = graph_rdepends(&ga,&g,"Master",src) ;
+	if (!r) 
+	{
+		strerr_warnwu2x("find services depending for: ","Master") ;
+		return 0 ;
+	}
+	graph_free(&g) ;
+	stralloc_free(&sagraph) ;
+	genalloc_deepfree(stralist,&tokeep,stra_free) ;*/
+	memcpy(src + info->tree.len + SS_SVDIRS_LEN, SS_SVC,SS_SVC_LEN) ;
+	src[info->tree.len + SS_SVDIRS_LEN + SS_SVC_LEN] = 0 ;
 	
 	if (!dir_get(&ga,src,"",S_IFDIR))
 	{
@@ -69,7 +98,7 @@ int doit(ssexec_t *info, unsigned int what, char const *const *envp)
 	{
 		VERBO3 strerr_warni4x("no classic service for tree: ",info->treename.s," to ", what ? "start" : "stop") ;
 	}
-	/** add transparent Master to start the db*/
+
 	if (!stra_add(&ga,"Master"))
 	{
 		VERBO3 strerr_warnwu2x("add Master as service to ", what ? "start" : "stop") ;
-- 
GitLab