diff --git a/client.go b/client.go index cf51289..ef5c089 100644 --- a/client.go +++ b/client.go @@ -41,6 +41,7 @@ type Client struct { tlscfg *tls.Config api_prefix string + ext_mtx sync.Mutex ext_svcs []Service ctl *http.Server // control server @@ -1011,7 +1012,9 @@ func (c *Client) StartService(data interface{}) { } func (c *Client) StartExtService(svc Service, data interface{}) { + c.ext_mtx.Lock() c.ext_svcs = append(c.ext_svcs, svc) + c.ext_mtx.Unlock() c.wg.Add(1) go svc.RunTask(&c.wg) } diff --git a/server.go b/server.go index 49be7bd..cdaebb4 100644 --- a/server.go +++ b/server.go @@ -29,6 +29,7 @@ type Server struct { tlscfg *tls.Config wg sync.WaitGroup + ext_mtx sync.Mutex ext_svcs []Service stop_req atomic.Bool stop_chan chan bool @@ -913,7 +914,9 @@ func (s *Server) StartService(cfg interface{}) { } func (s *Server) StartExtService(svc Service, data interface{}) { + s.ext_mtx.Lock() s.ext_svcs = append(s.ext_svcs, svc) + s.ext_mtx.Unlock() s.wg.Add(1) go svc.RunTask(&s.wg) }