I have an aysnc threadpool model for my network connection management. A single dispatcher thread that keeps calling poll() and a worker thread pool that either read/write once poll() indicates so.
Consider a case where poll() indicates a socket is read-ready. But the worker thread hasn't processed the read yet. I disable read-poll while the worker thread hasn't processed the read. Now the remote side disconnects and poll() returns with POLLERR/POLLHUP. What happens when the worker thread does the read() call after this?
Does read() return <0 even though there is some data that hasn't been read yet? Or
Does read() read data from the network even though the socket had a POLLERR/POLLHUP?