We may only emit the readReady signal once for every event loop
iteration. The previous implementation lead to the situation that the
socket engine stopped reading socket data when bursts of data was
received. In this case several readReady signals were fired. The socket
engine obtained the pending datagrams (not only the first one) and for
the following readReady signal no datagram was present. In this case the
socket engine stops reading and the engine stalls.
The new approach emits the readyRead signal at the most once every event
loop iteration. The list of new pending datagrams is queued to be added
to the "real" pending datagram list at the same time as the readyRead
signal. Thereby we avoid the situation that a client can read all the
datagrams before readyRead is emitted.
One more advantage of having the worker handle the pending datagrams
is that we no longer have to access the socket engine's members inside
the callback. Thus we avoid the situation, where a late callback can
make the application crash when the socket engine has already been
deleted.
Task-number: QTBUG-53472
Task-number: QTBUG-53471
Task-number: QTBUG-55895
Change-Id: Ia6d21cb635a40e7bd9e0213bb3a5c54ebc1220eb
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>