edit: Fix how asyncReader writes to error channel.

This commit is contained in:
Qi Xiao 2016-02-21 18:12:51 +00:00
parent 34e4f68bc0
commit 0396de6b91

View File

@ -101,20 +101,19 @@ func (ar *AsyncReader) Run() {
// BUG(xiaq): AsyncReader relies on the undocumented fact // BUG(xiaq): AsyncReader relies on the undocumented fact
// that (*os.File).Read returns an *os.File.PathError // that (*os.File).Read returns an *os.File.PathError
patherr, ok := err.(*os.PathError) //.Err patherr, ok := err.(*os.PathError) //.Err
if !ok { if ok && patherr.Err == syscall.EWOULDBLOCK || patherr.Err == syscall.EAGAIN {
ar.errCh <- err
return
}
e := patherr.Err
if e == syscall.EWOULDBLOCK || e == syscall.EAGAIN {
break ReadRune break ReadRune
} else { } else {
ar.errCh <- err select {
case ar.errCh <- err:
case <-ar.ctrlCh:
ar.rCtrl.Read(cBuf[:])
return return
} }
} }
} }
} }
}
} }
// Quit terminates the loop of Run. // Quit terminates the loop of Run.