Skip to content

Commit

Permalink
removed useless if block
Browse files Browse the repository at this point in the history
  • Loading branch information
HeavyHorst committed Nov 14, 2016
1 parent 3288ea9 commit 15ea34f
Showing 1 changed file with 25 additions and 27 deletions.
52 changes: 25 additions & 27 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,37 +153,35 @@ func (e *Executor) CancelOnExit(ctx context.Context, cancel context.CancelFunc)
e.childLock.RUnlock()

for {
if notNil {
select {
case <-ctx.Done():
return
case code := <-exitChan:
// wait a little bit to give the process time to start
// in case of a reload
time.Sleep(1 * time.Second)
e.childLock.RLock()
nexitChan := e.child.ExitCh()
// the exitChan has changed which means the process was reloaded
// don't exit in this case
if nexitChan != exitChan {
exitChan = nexitChan
select {
case <-ctx.Done():
return
case code := <-exitChan:
// wait a little bit to give the process time to start
// in case of a reload
time.Sleep(1 * time.Second)
e.childLock.RLock()
nexitChan := e.child.ExitCh()
// the exitChan has changed which means the process was reloaded
// don't exit in this case
if nexitChan != exitChan {
exitChan = nexitChan
e.childLock.RUnlock()
continue
}
// the process exited - stop
e.childLock.RUnlock()
if code != 0 {
e.logger.Error(fmt.Sprintf("(child) process exited unexpectedly with code: %d", code))
if e.restartOnFailure {
e.restartChild()
e.childLock.RLock()
exitChan = e.child.ExitCh()
e.childLock.RUnlock()
continue
}
// the process exited - stop
e.childLock.RUnlock()
if code != 0 {
e.logger.Error(fmt.Sprintf("(child) process exited unexpectedly with code: %d", code))
if e.restartOnFailure {
e.restartChild()
e.childLock.RLock()
exitChan = e.child.ExitCh()
e.childLock.RUnlock()
continue
}
}
cancel()
}
cancel()
}
}
}
Expand Down

0 comments on commit 15ea34f

Please sign in to comment.