Improve Continuous integration and fix concurrency bugs (#66)
- improvements to the continuous GH actions - fix edge case concurrency bugs with Process.start() and state transitions discovered setting up CI.
This commit is contained in:
@@ -133,9 +133,24 @@ func (p *Process) start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// There is the possibility of a hard to replicate race condition where
|
||||
// curState *WAS* StateStopped but by the time we get to the p.stateMutex.Lock()
|
||||
// below, it's value has changed!
|
||||
|
||||
p.stateMutex.Lock()
|
||||
defer p.stateMutex.Unlock()
|
||||
|
||||
// with the exclusive lock, check if p.state is StateStopped, which is the only valid state
|
||||
// to transition from to StateReady
|
||||
|
||||
if p.state != StateStopped {
|
||||
if p.state == StateReady {
|
||||
return nil
|
||||
} else {
|
||||
return fmt.Errorf("start() can not proceed expected StateReady but process is in %v", p.state)
|
||||
}
|
||||
}
|
||||
|
||||
if err := p.setState(StateStarting); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user