mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-01 00:23:56 +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
	 Tonis Tiigi
					Tonis Tiigi