Fixes from code review
This commit is contained in:
parent
5e225a23cb
commit
1b3e8db72f
2 changed files with 8 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* mdns.h - mDNS/DNS-SD library - Public Domain - 2017 Mattias Jansson
|
/* mdns.h - mDNS/DNS-SD library v1.4.3 - Public Domain - 2017 Mattias Jansson
|
||||||
*
|
*
|
||||||
* This library provides a cross-platform mDNS and DNS-SD library in C.
|
* This library provides a cross-platform mDNS and DNS-SD library in C.
|
||||||
* The implementation is based on RFC 6762 and RFC 6763.
|
* The implementation is based on RFC 6762 and RFC 6763.
|
||||||
|
|
|
@ -193,7 +193,7 @@ int Discoverer::listenForQueryResponses()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start listening on all sockets
|
// Start listening on all sockets
|
||||||
for (int socket : sockets) {
|
for (int socket : std::as_const(sockets)) {
|
||||||
QSocketNotifier *socketNotifier = new QSocketNotifier(socket, QSocketNotifier::Read);
|
QSocketNotifier *socketNotifier = new QSocketNotifier(socket, QSocketNotifier::Read);
|
||||||
QObject::connect(socketNotifier, &QSocketNotifier::activated, [this](QSocketDescriptor socket) {
|
QObject::connect(socketNotifier, &QSocketNotifier::activated, [this](QSocketDescriptor socket) {
|
||||||
MdnsService discoveredService;
|
MdnsService discoveredService;
|
||||||
|
@ -257,7 +257,7 @@ int countCommonLeadingBits(quint32 int1, quint32 int2) {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QHostAddress findBestAddressMatchV4(QVector<QHostAddress> hostAddresses, const struct sockaddr *fromAddress)
|
static QHostAddress findBestAddressMatchV4(const QVector<QHostAddress> &hostAddresses, const struct sockaddr *fromAddress)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!hostAddresses.empty());
|
Q_ASSERT(!hostAddresses.empty());
|
||||||
if (hostAddresses.size() == 1 || fromAddress == nullptr) {
|
if (hostAddresses.size() == 1 || fromAddress == nullptr) {
|
||||||
|
@ -291,7 +291,7 @@ static QHostAddress findBestAddressMatchV4(QVector<QHostAddress> hostAddresses,
|
||||||
return matchingIp;
|
return matchingIp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QHostAddress findBestAddressMatchV6(QVector<QHostAddress> hostAddresses, const struct sockaddr *fromAddress)
|
static QHostAddress findBestAddressMatchV6(const QVector<QHostAddress>& hostAddresses, const struct sockaddr *fromAddress)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!hostAddresses.empty());
|
Q_ASSERT(!hostAddresses.empty());
|
||||||
// We could do the same logic for v6 that we do for V4, but we don't care that much about IPv6
|
// We could do the same logic for v6 that we do for V4, but we don't care that much about IPv6
|
||||||
|
@ -595,15 +595,11 @@ void Announcer::stopAnnouncing()
|
||||||
|
|
||||||
void Announcer::stopListeningForQueries()
|
void Announcer::stopListeningForQueries()
|
||||||
{
|
{
|
||||||
if (socketNotifier != nullptr) {
|
|
||||||
delete socketNotifier;
|
delete socketNotifier;
|
||||||
socketNotifier = nullptr;
|
socketNotifier = nullptr;
|
||||||
}
|
|
||||||
if (socketNotifierV6 != nullptr) {
|
|
||||||
delete socketNotifierV6;
|
delete socketNotifierV6;
|
||||||
socketNotifierV6 = nullptr;
|
socketNotifierV6 = nullptr;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Announcer::sendMulticastAnnounce(bool isGoodbye)
|
void Announcer::sendMulticastAnnounce(bool isGoodbye)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue