summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-01-20 12:30:26 -0800
committerThiago Macieira <thiago.macieira@intel.com>2015-01-22 04:44:10 +0100
commita4c837b3a1168ab07415501f141395dfffc3ed18 (patch)
treefb2b2560b1ba6a9e880f871dbb0ed195b4071ee6 /src/network
parent358a9ac9362917e644e4c09c8d5c85d13faf5503 (diff)
Fix QUdpSocket's emission of readyRead()
The documentation says that QUdpSocket emits readyRead() only for one datagram and that if you don't read it, the class will not emit again. That should be implemented by disabling of the socket notifier once we have the datagram already read, but was broken. In turn, that breakage caused a live-lock of the event loop: since we didn't disable the notifier nor read the pending datagram, the event loop would fire every time for the same datagram. The re-enabling of the notifier was already working. Task-number: QTBUG-43857 Change-Id: Ic5d393bfd36e48a193fcffff13bb32ad390b5fe8 Reviewed-by: Peter Hartmann <phartmann@blackberry.com> Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/socket/qabstractsocket.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 604214ce8e..5a1ad40b90 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -740,8 +740,15 @@ bool QAbstractSocketPrivate::canReadNotification()
return true;
}
- if ((isBuffered || socketType != QAbstractSocket::TcpSocket) && socketEngine)
- socketEngine->setReadNotificationEnabled(readBufferMaxSize == 0 || readBufferMaxSize > q->bytesAvailable());
+ if (socketEngine) {
+ // turn the socket engine off if we've either:
+ // - got pending datagrams
+ // - reached the buffer size limit
+ if (isBuffered)
+ socketEngine->setReadNotificationEnabled(readBufferMaxSize == 0 || readBufferMaxSize > q->bytesAvailable());
+ else if (socketType != QAbstractSocket::TcpSocket)
+ socketEngine->setReadNotificationEnabled(!socketEngine->hasPendingDatagrams());
+ }
// reset the read socket notifier state if we reentered inside the
// readyRead() connected slot.