windows: Fix a few races
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
@@ -111,6 +111,10 @@ func (t *task) Info() runtime.TaskInfo {
|
||||
}
|
||||
|
||||
func (t *task) Start(ctx context.Context) error {
|
||||
if p := t.getProcess(t.id); p != nil {
|
||||
return errors.Wrap(errdefs.ErrFailedPrecondition, "task already started")
|
||||
}
|
||||
|
||||
conf := newWindowsProcessConfig(t.spec.Process, t.io)
|
||||
p, err := t.newProcess(ctx, t.id, conf, t.io)
|
||||
if err != nil {
|
||||
@@ -136,13 +140,13 @@ func (t *task) Pause(ctx context.Context) error {
|
||||
t.Lock()
|
||||
t.status = runtime.PausedStatus
|
||||
t.Unlock()
|
||||
}
|
||||
if err == nil {
|
||||
|
||||
t.publisher.Publish(ctx,
|
||||
runtime.TaskPausedEventTopic,
|
||||
&eventsapi.TaskPaused{
|
||||
ContainerID: t.id,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "hcsshim failed to pause task")
|
||||
}
|
||||
@@ -157,13 +161,13 @@ func (t *task) Resume(ctx context.Context) error {
|
||||
t.Lock()
|
||||
t.status = runtime.RunningStatus
|
||||
t.Unlock()
|
||||
}
|
||||
if err == nil {
|
||||
|
||||
t.publisher.Publish(ctx,
|
||||
runtime.TaskResumedEventTopic,
|
||||
&eventsapi.TaskResumed{
|
||||
ContainerID: t.id,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "hcsshim failed to resume task")
|
||||
}
|
||||
@@ -313,7 +317,6 @@ func (t *task) newProcess(ctx context.Context, id string, conf *hcsshim.ProcessC
|
||||
id: id,
|
||||
pid: pid,
|
||||
io: pset,
|
||||
status: runtime.CreatedStatus,
|
||||
task: t,
|
||||
exitCh: make(chan struct{}),
|
||||
conf: conf,
|
||||
|
Reference in New Issue
Block a user