User 'defer Unlock' to replace two 'Unlock's

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
This commit is contained in:
Yanqiang Miao 2017-05-06 14:21:16 +08:00
parent 12d65ceb50
commit f59c7a87da

View File

@ -70,13 +70,12 @@ func (m *Monitor) Start(c *exec.Cmd) error {
ExitCh: make(chan int, 1),
}
m.Lock()
defer m.Unlock()
// start the process
if err := rc.c.Start(); err != nil {
m.Unlock()
return err
}
m.cmds[rc.c.Process.Pid] = rc
m.Unlock()
return nil
}