d_nqueue.push_back(nr);
}
- bool removeIf(const string& remote, uint16_t id, const DNSName& domain)
+ bool removeIf(const ComboAddress& remote, uint16_t id, const DNSName& domain)
{
ServiceTuple stRemote, stQueued;
parseService(remote, stRemote);
- for (d_nqueue_t::iterator i = d_nqueue.begin(); i != d_nqueue.end(); ++i) {
+ for (auto i = d_nqueue.begin(); i != d_nqueue.end(); ++i) {
parseService(i->ip, stQueued);
if (i->id == id && stQueued.host == stRemote.host && i->domain == domain) {
d_nqueue.erase(i);
{
UeberBackend* B = P->getBackend();
ComboAddress from;
- Utility::socklen_t fromlen;
char buffer[1500];
int sock;
- ssize_t size;
set<int> fds = {d_nsock4, d_nsock6};
// receive incoming notifications on the nonblocking socket and take them off the list
while (waitForMultiData(fds, 0, 0, &sock) > 0) {
- fromlen = sizeof(from);
- size = recvfrom(sock, buffer, sizeof(buffer), 0, (struct sockaddr*)&from, &fromlen);
- if (size < 0)
+ Utility::socklen_t fromlen = sizeof(from);
+ const auto size = recvfrom(sock, buffer, sizeof(buffer), 0, (struct sockaddr*)&from, &fromlen);
+ if (size < 0) {
break;
+ }
DNSPacket p(true);
p.setRemote(&from);
continue;
}
- if (p.d.rcode)
+ if (p.d.rcode) {
g_log << Logger::Warning << "Received unsuccessful notification report for '" << p.qdomain << "' from " << from.toStringWithPort() << ", error: " << RCode::to_s(p.d.rcode) << endl;
+ }
- if (d_nq.removeIf(from.toStringWithPort(), p.d.id, p.qdomain))
+ if (d_nq.removeIf(from.toStringWithPort(), p.d.id, p.qdomain)) {
g_log << Logger::Notice << "Removed from notification list: '" << p.qdomain << "' to " << from.toStringWithPort() << " " << (p.d.rcode ? RCode::to_s(p.d.rcode) : "(was acknowledged)") << endl;
+ }
else {
g_log << Logger::Warning << "Received spurious notify answer for '" << p.qdomain << "' from " << from.toStringWithPort() << endl;
// d_nq.dump();
d_nq.removeIf(remote.toStringWithPort(), id, domain); // Remove, we'll never be able to notify
continue; // don't try to notify what we can't!
}
- if (d_preventSelfNotification && AddressIsUs(remote))
+ if (d_preventSelfNotification && AddressIsUs(remote)) {
continue;
+ }
sendNotification(remote.sin4.sin_family == AF_INET ? d_nsock4 : d_nsock6, domain, remote, id, B);
drillHole(domain, ip);
g_log << Logger::Warning << "Error trying to resolve '" << ip << "' for notifying '" << domain << "' to server: " << re.reason << endl;
}
}
- else
+ else {
g_log << Logger::Warning << "Notification for " << domain << " to " << ip << " failed after retries" << endl;
+ }
}
return d_nq.earliest();