guarded ext_svs with ext_mtx in client.go and server.go
This commit is contained in:
parent
b792997184
commit
74fb40d44f
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user