Details
Description
QAbstractSocket, QNativeSocketEngine etc rely on QSocketNotifier having unix like behaviour when the socket is closed.
i.e. if you enable the read notifier, and the socket is already closed by the remote then it will trigger next time the event loop is entered.
On windows, WSAAsyncSelect (and WSAEventSelect) will only send the FD_CLOSE event once. There is no way to re-enable it to be sent again.
This is in contrast to FD_READ which behaves as expected as long as the socket is connected.
When receiving TCP FIN or RST, FD_CLOSE is signalled exactly once.
Currently we treat FD_CLOSE and FD_READ the same, which works most of the time.
The problems happen when not all of the data is read, or the exact amount of available data is read but the client code expects another readyRead() signal.
This seems to cause some unstable autotests e.g. tst_QNetworkReply::ioPostToHttpFromSocket(128k+1 ...) often fails on windows because the readyRead() signal expected when the socket is closed is not received.
QNetworkReplyHttpImplPrivate::_q_bufferOutgoingData is called multiple times, and all the expected data is received.
However QNetworkReplyHttpImplPrivate::_q_bufferOutgoingDataFinished is not called.