rawexec: fix race around h.procState
This commit is contained in:
parent
ac12ae1729
commit
616801417c
|
@ -27,19 +27,25 @@ type rawExecTaskHandle struct {
|
|||
}
|
||||
|
||||
func (h *rawExecTaskHandle) IsRunning() bool {
|
||||
h.stateLock.RLock()
|
||||
defer h.stateLock.RUnlock()
|
||||
return h.procState == drivers.TaskStateRunning
|
||||
}
|
||||
|
||||
func (h *rawExecTaskHandle) run() {
|
||||
|
||||
// since run is called immediately after the handle is created this
|
||||
// Since run is called immediately after the handle is created this
|
||||
// ensures the exitResult is initialized so we avoid a nil pointer
|
||||
// thus it does not need to be included in the lock
|
||||
// thus it does not need to be included in the lock.
|
||||
h.stateLock.Lock()
|
||||
if h.exitResult == nil {
|
||||
h.exitResult = &drivers.ExitResult{}
|
||||
}
|
||||
h.stateLock.Unlock()
|
||||
|
||||
// Block until process exits
|
||||
ps, err := h.exec.Wait()
|
||||
|
||||
h.stateLock.Lock()
|
||||
defer h.stateLock.Unlock()
|
||||
|
||||
|
|
Loading…
Reference in a new issue