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