Update windows locking code
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
d18af8699c
commit
f945cdc704
@ -89,6 +89,13 @@ func (p *process) ExitCode() (uint32, time.Time, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *process) Start(ctx context.Context) (err error) {
|
func (p *process) Start(ctx context.Context) (err error) {
|
||||||
|
// If we fail, close the io right now
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
p.io.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
var hp hcsshim.Process
|
var hp hcsshim.Process
|
||||||
if hp, err = p.task.hcsContainer.CreateProcess(p.conf); err != nil {
|
if hp, err = p.task.hcsContainer.CreateProcess(p.conf); err != nil {
|
||||||
return errors.Wrapf(err, "failed to create process")
|
return errors.Wrapf(err, "failed to create process")
|
||||||
|
@ -104,17 +104,19 @@ func (t *task) Info() runtime.TaskInfo {
|
|||||||
|
|
||||||
func (t *task) Start(ctx context.Context) error {
|
func (t *task) Start(ctx context.Context) error {
|
||||||
conf := newProcessConfig(t.spec.Process, t.io)
|
conf := newProcessConfig(t.spec.Process, t.io)
|
||||||
if _, err := t.newProcess(ctx, t.id, conf, t.io); err != nil {
|
p, err := t.newProcess(ctx, t.id, conf, t.io)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := p.Start(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
t.publisher.Publish(ctx,
|
t.publisher.Publish(ctx,
|
||||||
runtime.TaskStartEventTopic,
|
runtime.TaskStartEventTopic,
|
||||||
&eventsapi.TaskStart{
|
&eventsapi.TaskStart{
|
||||||
ContainerID: t.id,
|
ContainerID: t.id,
|
||||||
Pid: t.pid,
|
Pid: t.pid,
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,11 +184,6 @@ func (t *task) Exec(ctx context.Context, id string, opts runtime.ExecOpts) (runt
|
|||||||
if pset, err = newPipeSet(ctx, opts.IO); err != nil {
|
if pset, err = newPipeSet(ctx, opts.IO); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
pset.Close()
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
conf := newProcessConfig(spec, pset)
|
conf := newProcessConfig(spec, pset)
|
||||||
p, err := t.newProcess(ctx, id, conf, pset)
|
p, err := t.newProcess(ctx, id, conf, pset)
|
||||||
@ -284,8 +281,6 @@ func (t *task) newProcess(ctx context.Context, id string, conf *hcsshim.ProcessC
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
t.Unlock()
|
|
||||||
t.Lock()
|
|
||||||
wp := &process{
|
wp := &process{
|
||||||
id: id,
|
id: id,
|
||||||
pid: pid,
|
pid: pid,
|
||||||
@ -293,6 +288,7 @@ func (t *task) newProcess(ctx context.Context, id string, conf *hcsshim.ProcessC
|
|||||||
status: runtime.CreatedStatus,
|
status: runtime.CreatedStatus,
|
||||||
task: t,
|
task: t,
|
||||||
exitCh: make(chan struct{}),
|
exitCh: make(chan struct{}),
|
||||||
|
conf: conf,
|
||||||
}
|
}
|
||||||
t.processes[id] = wp
|
t.processes[id] = wp
|
||||||
t.Unlock()
|
t.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user