golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
121.15k stars 17.37k forks source link

runtime: sockets closed by remote peer may remain undetected by poller #6753

Open remyoudompheng opened 10 years ago

remyoudompheng commented 10 years ago
I have observed a network TCP server blocked on a Write although the client (Go program
located on a remote machine) has closed the connection.

So far I have been unable to produce a minimal reproducer.

My hypothesis is that the poller is not handling EPOLLRDHUP correctly. map epoll_ctl(2)
says that it means: "Stream socket peer closed connection, or shut down writing
half of  connection."
But when obtaining EPOLLRDHUP from the socket the poller wakes up WaitRead() but not
WaitWrite(), so if the EPOLLRDHUP was generated by a remote close, waiting writers will
never wake up (one would expect something like "connection reset by peer").

Using linux/amd64.
dvyukov commented 10 years ago

Comment 1:

Writes must not be unblocked/prohibited after EPOLLRDHUP, writing is exactly what server
is supposed to do after EPOLLRDHUP (shutdown(SHUT_WR) on client).
If the client does close(fd), then the server receives EPOLLRDHUP | EPOLLHUP | EPOLLERR,
so writes must be unblocked.
So far I do not see where the problem is. Do you use CloseRead/CloseWrite?
rsc commented 10 years ago

Comment 2:

Labels changed: added go1.3maybe.

rsc commented 10 years ago

Comment 3:

Labels changed: added release-none, removed go1.3maybe.

rsc commented 10 years ago

Comment 4:

Labels changed: added repo-main.

methane commented 5 years ago

ref: #15735