Create atomic string to allow for simpler logic

This commit is contained in:
Dane Everitt
2020-11-06 21:14:29 -08:00
parent a74be8f4eb
commit 3fce1b98d5
6 changed files with 62 additions and 41 deletions

View File

@@ -136,7 +136,7 @@ func (e *Environment) Stop() error {
// If the process is already offline don't switch it back to stopping. Just leave it how
// it is and continue through to the stop handling for the process.
if e.State() != environment.ProcessOfflineState {
if e.State.Load() != environment.ProcessOfflineState {
e.setState(environment.ProcessStoppingState)
}
@@ -217,7 +217,7 @@ func (e *Environment) Terminate(signal os.Signal) error {
// If the container is not running but we're not already in a stopped state go ahead
// and update things to indicate we should be completely stopped now. Set to stopping
// first so crash detection is not triggered.
if e.State() != environment.ProcessOfflineState {
if e.State.Load() != environment.ProcessOfflineState {
e.setState(environment.ProcessStoppingState)
e.setState(environment.ProcessOfflineState)
}