fix deadlock

This commit is contained in:
Asim Aslam 2020-02-07 13:55:55 +00:00
parent fe7f5a4134
commit 0755084a59

View File

@ -70,17 +70,19 @@ func (s *service) streamOutput() {
go io.Copy(s.output, s.PID.Error) go io.Copy(s.output, s.PID.Error)
} }
func (s *service) ShouldStart() bool { func (s *service) shouldStart() bool {
s.RLock()
defer s.RUnlock()
if s.running { if s.running {
return false return false
} }
return s.maxRetries < s.retries return s.maxRetries < s.retries
} }
func (s *service) ShouldStart() bool {
s.RLock()
defer s.RUnlock()
return s.shouldStart()
}
func (s *service) Running() bool { func (s *service) Running() bool {
s.RLock() s.RLock()
defer s.RUnlock() defer s.RUnlock()
@ -92,7 +94,7 @@ func (s *service) Start() error {
s.Lock() s.Lock()
defer s.Unlock() defer s.Unlock()
if !s.ShouldStart() { if !s.shouldStart() {
return nil return nil
} }