mirror of
https://github.com/datarhei/core.git
synced 2025-10-05 16:07:07 +08:00
Fix crash while stopping a process that is currently starting
This commit is contained in:
@@ -796,8 +796,18 @@ func (p *process) stop(wait bool, reason string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If the process in starting state, wait until the process has been started
|
||||
for {
|
||||
if p.getState() == stateStarting {
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
// If the process is already in the finishing state, don't do anything
|
||||
if p.getState() == stateFinishing {
|
||||
if state, _ := p.setState(stateFinishing); state == stateFinishing {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -805,8 +815,6 @@ func (p *process) stop(wait bool, reason string) error {
|
||||
p.stopReason = reason
|
||||
p.stopReasonLock.Unlock()
|
||||
|
||||
p.setState(stateFinishing)
|
||||
|
||||
p.logger.Info().Log("Stopping")
|
||||
p.debuglogger.WithFields(log.Fields{
|
||||
"state": p.getStateString(),
|
||||
|
Reference in New Issue
Block a user