Fix SSDP Discovery reliability (#756)

This commit is contained in:
LordGrey 2020-04-05 19:41:02 +02:00 committed by GitHub
parent 253cd18e89
commit 7773d07571
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,11 +42,14 @@ const QString SSDPDiscover::getFirstService(const searchType& type, const QStrin
// search // search
sendSearch(st); sendSearch(st);
_udpSocket->waitForReadyRead(timeout_ms); if ( _udpSocket->waitForReadyRead(timeout_ms) )
{
while (_udpSocket->hasPendingDatagrams()) while (_udpSocket->waitForReadyRead(500))
{ {
QByteArray datagram; QByteArray datagram;
while (_udpSocket->hasPendingDatagrams())
{
datagram.resize(_udpSocket->pendingDatagramSize()); datagram.resize(_udpSocket->pendingDatagramSize());
QHostAddress sender; QHostAddress sender;
quint16 senderPort; quint16 senderPort;
@ -123,6 +126,8 @@ const QString SSDPDiscover::getFirstService(const searchType& type, const QStrin
} }
} }
} }
}
}
Debug(_log,"Search timeout, service [%s] not found", QSTRING_CSTR(st) ); Debug(_log,"Search timeout, service [%s] not found", QSTRING_CSTR(st) );
return QString(); return QString();
} }