Priority: P2: Important
Resolution: Out of scope
Affects Version/s: 5.10.0, 5.11
Fix Version/s: None
Component/s: Network: Sockets
Environment:Tested on macOS 10.13 and linux, suspected to happen at least also on macOS 10.12 and on windows.
The parent process should never terminate as the client doesn't initiate the connection drop and always reads all data available. The server makes sure all bytes are sent before it quits. Thus, the number of bytes read by the client should always be equal to the number of bytes written by the server.
(except in the "ouch" cases, which can theoretically happen, but haven't been observed here. But as the "ouch" would be printed, that would be visible)
However, there is code in QAbstractSocket and friends that prematurely closes the read notifier when failing to write to the socket. This failure to write can already happen on the client side before the regular TCP connection termination finishes because the OS already knows that the server has closed the socket. If the timing is such that the server writes a chunk of data, then immediately closes the connection, and the client tries to write to its socket before the data has arrived, the client will drop the read notification and never notice that further data arrives. That causes the data to be dropped.
The relevant close() and and abort() calls are in QAbstractSocketPrivate::writeToSocket() and NativeSocketEnginePrivate::nativeWrite(), in the unix and win variants.
I suspect a similar problem occurs when generating a read error on a socket that can still write. We call resetSocketLayer() in QAbstractSocketPrivate::readFromSocket() and QAbstractSocket::readData() in that case, which terminates the write notifier. Therefore we would never get notified of any remaining data being written.
|For Gerrit Dashboard: QTBUG-66230|
|219187,4||QAbstractSocket: Don't close() if we get a write error||dev||qt/qtbase||Status: ABANDONED||0||0|
|219283,3||blacklist qmlprofiler autotests which depend on AUT terminating||dev||qt/qtdeclarative||Status: MERGED||+2||0|