]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/dns.cpp
Merge guestpattern fix by peaveydk
[user/henk/code/inspircd.git] / src / dns.cpp
index ca08b93ba8063e0a902ab72f86a44bb208722b6a..fb38a23b966a1e431376e08f9b36fad966a7843d 100644 (file)
@@ -114,7 +114,7 @@ class RequestTimeout : public InspTimer
        int watchid;
        requestlist &rl;
  public:
-       RequestTimeout(InspIRCd* SI, DNSRequest* watching, int id, requestlist &requests) : InspTimer(2, time(NULL)), ServerInstance(SI), watch(watching), watchid(id), rl(requests)
+       RequestTimeout(unsigned long n, InspIRCd* SI, DNSRequest* watching, int id, requestlist &requests) : InspTimer(n, time(NULL)), ServerInstance(SI), watch(watching), watchid(id), rl(requests)
        {
                ServerInstance->Log(DEBUG, "New DNS timeout set on %08x", watching);
        }
@@ -126,7 +126,12 @@ class RequestTimeout : public InspTimer
                        /* Still exists, whack it */
                        if (rl.find(watchid)->second == watch)
                        {
-                               watch->OnError(RESOLVER_TIMEOUT, "Request timed out");
+                               if (ServerInstance->Res->Classes[watchid])
+                               {
+                                       ServerInstance->Res->Classes[watchid]->OnError(RESOLVER_TIMEOUT, "Request timed out");
+                                       delete ServerInstance->Res->Classes[watchid];
+                                       ServerInstance->Res->Classes[watchid] = NULL;
+                               }
                                rl.erase(rl.find(watchid));
                                delete watch;
                                ServerInstance->Log(DEBUG, "DNS timeout on %08x squished pointer", watch);
@@ -143,7 +148,7 @@ DNSRequest::DNSRequest(InspIRCd* Instance, DNS* dns, insp_inaddr server, int id,
        res = new unsigned char[512];
        *res = 0;
        memcpy(&myserver, &server, sizeof(insp_inaddr));
-       RequestTimeout* RT = new RequestTimeout(Instance, this, id, requests);
+       RequestTimeout* RT = new RequestTimeout(Instance->Config->dns_timeout ? Instance->Config->dns_timeout : 5, Instance, this, id, requests);
        Instance->Timers->AddTimer(RT); /* The timer manager frees this */
 }