mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
progress: make sure all channels have written before returning
Possible write on closed channel on cancellation before. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
@ -39,16 +39,18 @@ func Write(w Writer, name string, f func() error) {
|
||||
})
|
||||
}
|
||||
|
||||
func NewChannel(w Writer) chan *client.SolveStatus {
|
||||
func NewChannel(w Writer) (chan *client.SolveStatus, chan struct{}) {
|
||||
ch := make(chan *client.SolveStatus)
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
for {
|
||||
v, ok := <-ch
|
||||
if !ok {
|
||||
close(done)
|
||||
return
|
||||
}
|
||||
w.Write(v)
|
||||
}
|
||||
}()
|
||||
return ch
|
||||
return ch, done
|
||||
}
|
||||
|
Reference in New Issue
Block a user