Fix crash while stopping a process that is currently starting

This commit is contained in:
Ingo Oppermann 2025-04-10 15:30:40 +02:00
parent a18ff76672
commit ba77ec0ecf
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E

View File

@ -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(),