Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
os: (*os.File).SetDeadline() doesn't work after io.Copy(*net.TCPConn, *os.File) #28330
What version of Go are you using (
referenced this issue
Dec 18, 2018
I don't think much can be done here (without adding pointless new API) except to wait for Go 2.
To do sendfile, the net package needs to get at the file descriptor of the os.File, so that it can pass it down into poll.Sendfile. It can't get at its underlying poll.FD, so it has to make due with the integer file descriptor returned by Fd. Calls to Fd have to set the description in blocking mode for historical reasons.
In any case, I doubt this is a problem for any real program. Callers would have to both use a memory mappable descriptor in non-blocking mode, and want to call sendfile on it. And if it really is a problem, it can be worked around using unix.Setnonblock after io.Copy, since the blocking mode is a property of the file description rather than the file descriptor.