winrt: Remove partially read datagrams from queue

According to the documentation, datagrams that were
not completely read are discarded.

Change-Id: Id3a038d8aeeba05e8c8f92b70877f5f5297b89ca
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Andre de la Rocha <andre.rocha@qt.io>
This commit is contained in:
Oliver Wolff 2018-03-13 12:15:02 +01:00
parent 6696c37e00
commit 1f77332db0

View File

@ -1075,14 +1075,10 @@ qint64 QNativeSocketEngine::readDatagram(char *data, qint64 maxlen, QIpPacketHea
*header = datagram.header;
QByteArray readOrigin;
// Do not read the whole datagram. Put the rest of it back into the "queue"
if (maxlen < datagram.data.length()) {
if (maxlen < datagram.data.length())
readOrigin = datagram.data.left(maxlen);
datagram.data = datagram.data.remove(0, maxlen);
d->worker->pendingDatagrams.prepend(datagram);
} else {
else
readOrigin = datagram.data;
}
if (d->worker->pendingDatagrams.isEmpty()) {
qCDebug(lcNetworkSocket) << this << Q_FUNC_INFO << "That's all folks";
d->worker->emitDataReceived = true;