]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/dns.cpp
IT WORKS!
[user/henk/code/inspircd.git] / src / dns.cpp
index ec19ed397f9ec2f02a2adc60354f560e7a7711b3..8a274577e5b95cd46e552921820a06e26ca84d11 100644 (file)
@@ -11,6 +11,8 @@
  * ---------------------------------------------------
  */
 
+/* $Core: libIRCDasyncdns */
+
 /*
 dns.cpp - Nonblocking DNS functions.
 Very very loosely based on the firedns library,
@@ -117,7 +119,7 @@ class CacheTimer : public Timer
        CacheTimer(InspIRCd* Instance, DNS* thisdns)
                : Timer(3600, Instance->Time(), true), ServerInstance(Instance), dns(thisdns) { }
 
-       virtual void Tick(time_t TIME)
+       virtual void Tick(time_t)
        {
                dns->PruneCache();
        }
@@ -133,7 +135,7 @@ class RequestTimeout : public Timer
        {
        }
 
-       void Tick(time_t TIME)
+       void Tick(time_t)
        {
                if (ServerInstance->Res->requests[watchid] == watch)
                {
@@ -145,7 +147,7 @@ class RequestTimeout : public Timer
                                ServerInstance->Res->Classes[watchid] = NULL;
                        }
                        ServerInstance->Res->requests[watchid] = NULL;
-                       DELETE(watch);
+                       delete watch;
                        return;
                }
        }
@@ -211,6 +213,8 @@ inline void DNS::EmptyHeader(unsigned char *output, const DNSHeader *header, con
 /** Send requests we have previously built down the UDP socket */
 int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryType qt)
 {
+       ServerInstance->Log(DEBUG,"DNSRequest::SendRequests");
+
        unsigned char payload[sizeof(DNSHeader)];
 
        this->rr_class = 1;
@@ -240,6 +244,8 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp
                if (ServerInstance->SE->SendTo(dnsobj, (const char*)payload, length + 12, 0, (sockaddr *) &addr, sizeof(addr)) != length+12)
                        return -1;
        }
+
+       ServerInstance->Log(DEBUG,"Sent OK");
        return 0;
 }
 
@@ -360,6 +366,7 @@ void DNS::Rehash()
                if (!ServerInstance->BindSocket(this->GetFd(), portpass, "", false))
                {
                        /* Failed to bind */
+                       ServerInstance->Log(DEBUG,"Error binding dns socket");
                        ServerInstance->SE->Shutdown(this, 2);
                        ServerInstance->SE->Close(this);
                        this->SetFd(-1);
@@ -380,11 +387,16 @@ void DNS::Rehash()
                        }
                }
        }
+       else
+       {
+               ServerInstance->Log(DEBUG,"Error creating dns socket");
+       }
 }
 
 /** Initialise the DNS UDP socket so that we can send requests */
 DNS::DNS(InspIRCd* Instance) : ServerInstance(Instance)
 {
+       ServerInstance->Log(DEBUG,"DNS::DNS");
        /* Clear the Resolver class table */
        memset(Classes,0,sizeof(Classes));
 
@@ -947,6 +959,7 @@ void Resolver::TriggerCachedResult()
 /** High level abstraction of dns used by application at large */
 Resolver::Resolver(InspIRCd* Instance, const std::string &source, QueryType qt, bool &cached, Module* creator) : ServerInstance(Instance), Creator(creator), input(source), querytype(qt)
 {
+       ServerInstance->Log(DEBUG,"Resolver::Resolver");
        cached = false;
 
        CQ = ServerInstance->Res->GetCache(source);
@@ -1015,10 +1028,14 @@ Resolver::Resolver(InspIRCd* Instance, const std::string &source, QueryType qt,
                /* We shouldnt get here really */
                return;
        }
+       else
+       {
+               ServerInstance->Log(DEBUG,"DNS request id %d", this->myid);
+       }
 }
 
 /** Called when an error occurs */
-void Resolver::OnError(ResolverError e, const std::string &errormessage)
+void Resolver::OnError(ResolverError, const std::string&)
 {
        /* Nothing in here */
 }
@@ -1041,7 +1058,7 @@ Module* Resolver::GetCreator()
 }
 
 /** Process a socket read event */
-void DNS::HandleEvent(EventType et, int errornum)
+void DNS::HandleEvent(EventType, int)
 {
        /* Fetch the id and result of the next available packet */
        int resultnum = 0;
@@ -1101,6 +1118,7 @@ void DNS::HandleEvent(EventType et, int errornum)
 /** Add a derived Resolver to the working set */
 bool DNS::AddResolverClass(Resolver* r)
 {
+       ServerInstance->Log(DEBUG,"AddResolverClass %08lx", r);
        /* Check the pointers validity and the id's validity */
        if ((r) && (r->GetId() > -1))
        {