sysSocket.Recvfrom currently returns the error from the syscall instead of
the error from RawConn.Read. This is problematic when using SetReadDeadline.
cerr := s.rc.Read(func(fd uintptr) bool {
n, addr, err = unix.Recvfrom(int(fd), p, flags) // err == EAGAIN
return err != unix.EAGAIN // return false
})
// Since we return false we enter the poller, Read blocks until
// deadline elapses. cerr is an i/o timeout now.
if err != nil { // err is still EAGAIN from call to read
return n, addr, err // return EAGAIN instead of i/o timeout
}
sysSocket.Recvfrom currently returns the error from the syscall instead of the error from RawConn.Read. This is problematic when using SetReadDeadline.
The fix is to prefer returning cerr over err.