You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I never encountered this in real applications.
I guess there are more similar issues around Fd() and the runtime poller.
Maybe it's better to just leave this to Go 2 and make Fd not touch the blocking mode.
The text was updated successfully, but these errors were encountered:
@txg5214
I guess you tested this on macOS.
The bug only occurs on platforms where sendfile is used for copying *os.File to *net.TCPConn.
Those are Linux, DragonflyBSD, FreeBSD, Solaris and Windows.
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.
What version of Go are you using (
go version
)?go version go1.11.1 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Linux AMD64
What did you do?
This is the same as #22934
io.Copy()
usesnet.sendFile
to do the work, which calls(*os.File).Fd()
.go/src/net/sendfile_linux.go
Line 35 in 5ddb209
To reproduce, run the following code.
What did you expect to see?
panic: read |0: i/o timeout
What did you see instead?
got 456, deadline: 1540286817, now: 1540286820
I never encountered this in real applications.
I guess there are more similar issues around
Fd()
and the runtime poller.Maybe it's better to just leave this to Go 2 and make
Fd
not touch the blocking mode.The text was updated successfully, but these errors were encountered: