Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
net.TCPConn.CloseRead() will not cause the net.TCPConn.Read() return on windows but it can cause return on linux #41002
same code has different performace on windows and linux
Thank you for explaining. I’m trying to understand the Issue you are reporting. It is not that the code panics under linux and not under windows because the panic is in your code, not go.
The difference appears to be that under linux when you call CloseRead in another goroutine the Goroutine waiting in Read receives 3, nil on windows and 0, (some non nil error) on linux. Is that a correct summary?
@davecheney the summary is:
run the code by your self or show it to other developers,they will know what happened
@chenjie199234 can you please try this self contained program
in that order.
It appears that CloseRead behaves differently on Linux and Windows.
On Linux it makes Read return EOF, and (I assume) makes Write fail.
On Windows it makes Read return sent bytes, and (I assume) makes Write succeed.
I say either scenario is fine. There is a race here between Read and CloseRead, and result here depends on network stack implementation.
In my view, CloseRead cannot be used for anything useful. Only Close and CloseWrite are useful. Both ends of the connection should keep reading from the connection until EOF, if you do not want to loose some data.