Permalink
Browse files

make notification queue ipv6 compatible

  • Loading branch information...
1 parent 0c13e45 commit 3c8a71126d0a3bcd737ace67042f5c032ef2a4a2 @mind04 mind04 committed with mind04 Dec 22, 2013
Showing with 12 additions and 10 deletions.
  1. +12 −10 pdns/communicator.hh
View
@@ -68,26 +68,26 @@ class NotificationQueue
public:
void add(const string &domain, const string &ip)
{
+ const ComboAddress caIp(ip);
+
NotificationRequest nr;
nr.domain = domain;
- nr.ip = ip;
+ nr.ip = caIp.toStringWithPort();
nr.attempts = 0;
nr.id = Utility::random()%0xffff;
nr.next = time(0);
d_nqueue.push_back(nr);
}
-
+
bool removeIf(const string &remote, uint16_t id, const string &domain)
{
+ ServiceTuple stRemote, stQueued;
+ parseService(remote, stRemote);
+
for(d_nqueue_t::iterator i=d_nqueue.begin(); i!=d_nqueue.end(); ++i) {
- // cout<<i->id<<" "<<id<<endl;
- //cout<<i->ip<<" "<<remote<<endl;
- //cout<<i->domain<<" "<<domain<<endl;
- string remoteIP, ourIP, port;
- tie(remoteIP, port)=splitField(remote, ':');
- tie(ourIP, port)=splitField(i->ip, ':');
- if(i->id==id && ourIP == remoteIP && i->domain==domain) {
+ parseService(i->ip, stQueued);
+ if(i->id==id && stQueued.host == stRemote.host && i->domain==domain) {
d_nqueue.erase(i);
return true;
}
@@ -114,15 +114,17 @@ public:
}
return false;
}
-
+
time_t earliest()
{
time_t early=std::numeric_limits<time_t>::max() - 1;
for(d_nqueue_t::const_iterator i=d_nqueue.begin();i!=d_nqueue.end();++i)
early=min(early,i->next);
return early-time(0);
}
+
void dump();
+
private:
struct NotificationRequest
{

0 comments on commit 3c8a711

Please sign in to comment.