From 3027d3461e446eca1901527206cdc064dd8efca8 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Sat, 17 Feb 2018 15:24:50 -0800 Subject: [PATCH 1/2] Qt 5.10 seems to indicate pendingDatagramSizes of 0. Reading from these would block and causes an QAbstractSocket::TemporaryError to be thrown --- libraries/networking/src/udt/Socket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index 55643985c8..f705854bda 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -328,14 +328,14 @@ void Socket::checkForReadyReadBackup() { void Socket::readPendingDatagrams() { int packetSizeWithHeader = -1; - while ((packetSizeWithHeader = _udpSocket.pendingDatagramSize()) != -1) { + while ((packetSizeWithHeader = _udpSocket.pendingDatagramSize()) > 0) { // we're reading a packet so re-start the readyRead backup timer _readyReadBackupTimer->start(); // grab a time point we can mark as the receive time of this packet auto receiveTime = p_high_resolution_clock::now(); - + // setup a HifiSockAddr to read into HifiSockAddr senderSockAddr; From 0a92596452250881bec62a2faf9785603db6bf89 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Sun, 18 Feb 2018 10:04:22 -0800 Subject: [PATCH 2/2] don't rely on return value of pendingDatagramSize() when hasPendingDatagrams() is false --- libraries/networking/src/udt/Socket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp index f705854bda..af9ff76eb3 100644 --- a/libraries/networking/src/udt/Socket.cpp +++ b/libraries/networking/src/udt/Socket.cpp @@ -328,7 +328,7 @@ void Socket::checkForReadyReadBackup() { void Socket::readPendingDatagrams() { int packetSizeWithHeader = -1; - while ((packetSizeWithHeader = _udpSocket.pendingDatagramSize()) > 0) { + while (_udpSocket.hasPendingDatagrams() && (packetSizeWithHeader = _udpSocket.pendingDatagramSize()) != -1) { // we're reading a packet so re-start the readyRead backup timer _readyReadBackupTimer->start();