1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-01 02:30:39 +08:00

ctxio: fix buffer of 1 so goroutine exits when io completes.

This commit is contained in:
Juan Batiz-Benet
2014-12-24 05:50:05 -08:00
parent 989d3d4ce5
commit 0938471d1c

View File

@ -45,7 +45,7 @@ func (w *ctxWriter) Write(buf []byte) (int, error) {
buf2 := make([]byte, len(buf))
copy(buf2, buf)
c := make(chan ioret)
c := make(chan ioret, 1)
go func() {
n, err := w.w.Write(buf2)
@ -92,7 +92,7 @@ func NewReader(ctx context.Context, r io.Reader) *ctxReader {
func (r *ctxReader) Read(buf []byte) (int, error) {
buf2 := make([]byte, len(buf))
c := make(chan ioret)
c := make(chan ioret, 1)
go func() {
n, err := r.r.Read(buf2)