提交 c8504d54 编写于 作者: H holyfei 提交者: Gitee

backend: add close status chan for backend

Fix #I1TOQY

reason: 
1. add close status chan for backend
2. use closeStatusChan instead of directly closing
Signed-off-by: Nyangfeiyu <yangfeiyu2@huawei.com>
上级 4cc3990c
......@@ -60,7 +60,7 @@ func (b *Backend) Build(req *pb.BuildRequest, stream pb.Control_BuildServer) err
eg, ctx := errgroup.WithContext(ctx)
eg.Go(func() error {
b.syncBuildStatus(req.BuildID) <- struct{}{}
close(b.status[req.BuildID].startBuild)
b.closeStatusChan(req.BuildID)
var berr error
imageID, berr = builder.Build()
......
......@@ -63,3 +63,11 @@ func (b *Backend) syncBuildStatus(buildID string) chan struct{} {
b.Unlock()
return statusChan
}
func (b *Backend) closeStatusChan(buildID string) {
b.Lock()
if _, ok := b.status[buildID]; ok {
close(b.status[buildID].startBuild)
}
b.Unlock()
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册