From 0755084a598bdca5a4caa3980d21e21ec894896d Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Fri, 7 Feb 2020 13:55:55 +0000 Subject: [PATCH] fix deadlock --- runtime/service.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/runtime/service.go b/runtime/service.go index 0a40f2f7..8c8fffba 100644 --- a/runtime/service.go +++ b/runtime/service.go @@ -70,17 +70,19 @@ func (s *service) streamOutput() { go io.Copy(s.output, s.PID.Error) } -func (s *service) ShouldStart() bool { - s.RLock() - defer s.RUnlock() - +func (s *service) shouldStart() bool { if s.running { return false } - return s.maxRetries < s.retries } +func (s *service) ShouldStart() bool { + s.RLock() + defer s.RUnlock() + return s.shouldStart() +} + func (s *service) Running() bool { s.RLock() defer s.RUnlock() @@ -92,7 +94,7 @@ func (s *service) Start() error { s.Lock() defer s.Unlock() - if !s.ShouldStart() { + if !s.shouldStart() { return nil }